Git Cheat Sheet
The Git commands you actually reach for, searchable. Try "undo", "branch" or "stash".
Frequently asked questions
What's the difference between reset, revert and restore?
restore touches files (discard working changes), reset moves the branch pointer (undo local commits), revert makes a new commit that undoes an old one (safe on shared branches). Rule of thumb: pushed already? Use revert.
Merge or rebase?
Merge preserves history exactly as it happened; rebase rewrites your commits onto the latest base for a linear history. Both are fine — the one hard rule is never rebase commits that others have already pulled.
How do I get out of a broken state?
git status almost always tells you the next step. If mid-merge or mid-rebase, git merge --abort / git rebase --abort return you to safety. And git reflog can recover "lost" commits for about 90 days — in Git, very little is truly gone.
Last updated: 2026-07-13