developer4 sections · 25 items
Git Commands Quick Reference Cheat Sheet
Essential git commands organized by workflow: setup, daily use, branching, undoing changes, and collaboration.
Setup & Config
| Item | Value |
|---|---|
| Set username | git config --global user.name "Name" |
| Set email | git config --global user.email "email@example.com" |
| Init new repo | git init |
| Clone repo | git clone <url> |
| View config | git config --list |
Daily Workflow
| Item | Value |
|---|---|
| Check status | git status |
| Stage files | git add <file> or git add . |
| Commit | git commit -m "message" |
| View log | git log --oneline --graph |
| View diff | git diff |
| Pull latest | git pull origin main |
| Push changes | git push origin <branch> |
Branching & Merging
| Item | Value |
|---|---|
| Create branch | git branch <name> |
| Switch branch | git checkout <name> or git switch <name> |
| Create + switch | git checkout -b <name> |
| List branches | git branch -a |
| Merge branch | git merge <branch> |
| Delete branch | git branch -d <name> |
| Rebase | git rebase <branch> |
Undoing Changes
| Item | Value |
|---|---|
| Unstage file | git restore --staged <file> |
| Discard changes | git restore <file> |
| Amend last commit | git commit --amend |
| Revert a commit | git revert <hash> |
| Reset to commit | git reset --hard <hash> |
| Stash changes | git stash |
Tip: Use landscape orientation for wider tables
Related Tools
Stay Updated
Get notified about new tools, features, and exclusive deals. No spam, ever.