Skills › 💻 Terminal & git

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.

⏱ 30s

  1. Stage the forgotten change: git add <file>.
  2. Run git commit --amend --no-edit to add it to the last commit and keep the message.
  3. 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.

Practice in the feed →

Next crumbs

Sources