Ad space (banner)
🌿Git Lessons
Lesson 26 / 59

Fixing the Last Commit with git commit --amend

This lesson covers fixing your most recent commit with git commit --amend. It's for anyone searching "git commit --amend usage."

git commit --amend fixes the content or message of your most recent commit. Handy for "I got the commit message wrong" or "I forgot to include one file."

In Try It, run git commit --amend -m "Updated commit message". Your previous commit is overwritten with the new message.

A common early mistake is not realizing how risky amend is once a commit has already been shared (pushed) with others — amend effectively rewrites commit history, so doing it on a shared history can create inconsistencies between you and your teammates. In real teams, using amend as a final tweak — before pushing — on a commit that's still only yours locally, is the safe way to use it.

Git
Try it (type this into the pseudo terminal)
git commit --amend -m "Updated commit message"

🧑‍💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)