Fix your last commit with --amend
Forgot a file or made a typo in the message? Fold the fix into the commit you just made.
- Stage the forgotten change:
git add <file>. - Run
git commit --amend --no-editto add it to the last commit and keep the message. - Or run
git commit --amend -m "Better message"to rewrite the message too.
Tip: Amending rewrites the commit. Only do it before you push, or you'll need a force push.
Try it now: In a scratch repo, commit one file, then add a second one to that same commit with --amend.
Next crumbs
- 💻 Terminal & gitPark unfinished work with git stashNeed to switch branches but you're mid-change? Stash it, switch, and bring it back later.
- 💻 Terminal & gitSee your branches as a graphOne log command turns a wall of commit text into a readable branch map.
- 💻 Terminal & gitJump back with cd -Toggle between your last two directories, like Alt+Tab for folders.