I committed to the wrong branch
- $
- $
- $
Only if that commit isn't pushed yet.
$ git help --cheatsheet
Every command you'll actually use, grouped by what you're trying to do. Click any command to copy it.
Most commands just move changes between these four places.
Once per computer. Your name and email go into every commit.
The everyday loop: edit → add → commit.
A branch is just a movable label on a commit. They're cheap — use lots.
Pushed already? Prefer revert. Only rewrite commits nobody else has.
A drawer for half-finished work when you need a clean folder.
Use these anywhere a command expects a commit.
HEADHEAD~1HEAD^2a1b2c3dmain..featureorigin/main@{u}HEAD@{2}Files Git should never track. One pattern per line.
*.lognode_modules//build**/tmp.env!keep.logCommon mistakes and the exact commands that fix them.
Only if that commit isn't pushed yet.
Never rewrite history others already pulled.
Git keeps them for about 90 days.
Keeps any commits you made there. Or just git switch main.