Cheatsheet Pages / Git Cheatsheet

How to fix the last Git commit — git commit --amend

You just committed and immediately spot a typo in the message or a file you forgot to include.

git commit -m "Add login validation"   # normal commit
git commit --amend --no-edit           # fold new staged changes into the last commit

Good to know

--amend rewrites the most recent commit instead of adding a new one. Warning: don't amend commits already pushed.

Git Cheatsheet one-page card — 30 daily and rescue commands
The full one-page card — Git Cheatsheet. Get the complete cheatsheet on GitHub