Published March 27, 2026 · 16 min read
Git is the version control system used by virtually every software project on the planet. Whether you are working solo or on a team of hundreds, these are the commands you will use daily. We manage over 225 Git repositories and 16,000+ commits across our projects, so we know which commands matter and which ones are just noise.
This cheat sheet is organized by workflow, not alphabetically. You will learn commands in the order you actually use them.
Run these once when you first install Git:
This is your daily loop: check status, stage changes, commit, push.
Your commit messages should explain why you made a change, not what you changed (the diff shows that). Good: "Fix login timeout for users with slow connections." Bad: "Updated auth.js."
The conventional format is:
type(scope): description feat: Add dark mode toggle fix: Resolve 404 on user profile page docs: Update API documentation refactor: Simplify payment processing logic test: Add unit tests for cart service
Branches let you work on features without affecting the main codebase. This is the core of collaborative Git workflows.
Rebasing replays your commits on top of another branch, creating a cleaner history. Use it to keep feature branches up to date with main.
Rule of thumb: Never rebase branches that others have pulled. Rebase your own feature branches. Merge shared branches.
Everyone makes mistakes. Here is how to fix them without panicking.
Important: git reset --hard permanently deletes changes. Use --soft or --mixed (default) to keep your work. git revert is safer for shared branches because it does not rewrite history.
Stashing saves your uncommitted changes so you can switch branches without committing half-finished work.
Apply a specific commit from another branch to your current branch.
Binary search through commits to find which one introduced a bug.
Remove untracked files from the working directory.
Save time by shortening commands you use frequently:
git config --global alias.s "status" git config --global alias.co "checkout" git config --global alias.br "branch" git config --global alias.cm "commit -m" git config --global alias.lg "log --oneline --graph --all" git config --global alias.last "log -1 HEAD" git config --global alias.unstage "restore --staged"
Now git s shows status, git lg shows a visual log, and git cm "message" commits with a message.
git checkout main git pull git checkout -b feature/user-profiles # ... make changes ... git add . git commit -m "feat: Add user profile page" git push -u origin feature/user-profiles # Create pull request on GitHub # After review and merge, clean up: git checkout main git pull git branch -d feature/user-profiles
git checkout main git pull git checkout -b hotfix/fix-login-crash # ... fix the bug ... git add . git commit -m "fix: Resolve crash on login with empty email" git push -u origin hotfix/fix-login-crash # Create PR, merge immediately
| Task | Command |
|---|---|
| Create repo | git init |
| Clone repo | git clone URL |
| Check status | git status |
| Stage files | git add . |
| Commit | git commit -m "msg" |
| Push | git push |
| Pull | git pull |
| New branch | git checkout -b name |
| Merge | git merge branch |
| Undo commit | git reset --soft HEAD~1 |
| Stash | git stash |
| View log | git log --oneline |
650+ free developer tools including code formatters, diff viewers, and project scaffolders. No signup.
Browse Free Tools Side Hustle Guide