A concise reference for Git commands.


⚙️ Configure Git

🌍 Global (applies to all repositories)

# Set global name
git config --global user.name "Your Name"

# Set global email
git config --global user.email "[email protected]"

📂 Local (specific to a repository)

# Set local name (for this repo only)
git config --local user.name "Your Name"

# Set local email (for this repo only)
git config --local user.email "[email protected]"

🏗️ Initialize & Clone

🆕 Initialize a Git repository

git init

📥 Clone a repository

# Clone into a new directory
git clone [url]

# Clone into the current directory
git clone [url] .

# Clone into a specific directory
git clone [url] [path-to-clone]

📌 Stage & Snapshot

🔎 Check file status

git status

➕ Add files to the staging area

# Stage a specific file
git add [file]

# Stage all files
git add .

➖ Remove files from the staging area