Git Cheat Sheet

The most useful Git commands in one place, with examples.

Essential Git Commands by Category

A good Git cheat sheet gives you the command you need in under 10 seconds. Ours is organized by workflow stage: starting work (clone, init, checkout), making changes (add, commit, amend), syncing with remotes (fetch, pull, push), branching (branch, merge, rebase), and undoing mistakes (reset, revert, restore).

Each entry shows the minimal syntax to accomplish the task, with flags you'll actually use. We skip flags you'll never need and focus on the patterns that cover 95% of daily Git work. If you're constantly Googling the same commands, this cheat sheet makes those lookups instant.

Beyond basic commands, the cheat sheet covers workflow patterns: feature branching, interactive rebase for clean history, fixing merge conflicts, cherry-picking hotfixes, and recovering from common mistakes (detached HEAD, accidental branch deletion, force-push recovery).

Tips

  • Set up a global ~/.gitconfig with aliases: co = checkout, br = branch, st = status saves keystrokes.
  • git diff --staged shows what's already added (staged) but not yet committed — useful before git commit.
  • git branch -vv shows local branches with their upstream tracking branch and ahead/behind status.
  • git blame -w -L 10,20 file.js shows who last changed lines 10-20, ignoring whitespace-only changes (-w).

Ready to get started?

Open Git Cheat Sheet

New tools every week

Get notified. No spam.