Git Amend

Modify the most recent commit safely before pushing.

On this page

What is amend?

git commit --amend modifies the most recent commit.

Fix commit message

git commit --amend

Add forgotten file

git add forgotten-file.js
git commit --amend

Important warning

Do not amend commits that have already been pushed to shared branches.

When to use amend

  • Correct typos in commit message
  • Add small forgotten changes