🔧 Git Command Reference
Essential Git commands for version control workflows
Setup & Configuration
| Command | Description |
|---|---|
git config --global user.name "Name" |
Set your name for commits |
git config --global user.email "email@example.com" |
Set your email for commits |
git init |
Initialize a new Git repository |
git clone [url] |
Clone a repository from URL |
Basic Commands
| Command | Description |
|---|---|
git status |
Show working tree status |
git add [file] |
Stage specific file |
git add . |
Stage all changes |
git commit -m "message" |
Commit staged changes |
git push |
Push commits to remote |
git pull |
Fetch and merge remote changes |
git log |
Show commit history |
Branching
| Command | Description |
|---|---|
git branch |
List all branches |
git branch [name] |
Create new branch |
git checkout [branch] |
Switch to branch |
git checkout -b [branch] |
Create and switch to new branch |
git merge [branch] |
Merge branch into current branch |
git branch -d [branch] |
Delete branch |
Undoing Changes
| Command | Description |
|---|---|
git reset [file] |
Unstage file |
git reset --hard |
Discard all local changes |
git checkout -- [file] |
Discard changes in file |
git revert [commit] |
Create new commit that undoes changes |