Git Excited
"Nobody knows git"

How to Amend a Commit

It’s not uncommon to make a commit, only to realize shortly afterwards that you’ve either made a typo, forgot to mention something, or even over/under included files that should’ve been a part of that commit. Don’t worry, this type of situation is fairly common and easy to fix.

Git has an --amend flag that you can use when committing to change anything about the last commit you just made. This let’s you remedy whatever you just accidentally committed without having to create another commit and dirty up the commit log.

git commit -m "Made 2 changes" # this is a terrible commit message btw
# you realize that you actually made THREE changes, not two
git commit --amend -m "Made 3 changes"