How to Amend a Commit with git commit --amend
In a hurry? Watch our brief 1-minute vertical video that summarizes the info below.
Did you ever make a commit only to realize you forgot to add a file? Or maybe you made a typo in the commit message?
Don't worry, you don't have to create a new commit to fix this. You can simply amend the previous one.
A Word of Caution
You should only amend commits that have not been pushed to a remote repository yet. Amending a commit that other people have already based their work on can cause a lot of problems.
Adding a Forgotten File to the Last Commit
Let's say you forgot to add a file to your last commit. To add it, you first need to stage the file:
$ git add forgotten-file.txt
Then, you can run the git commit --amend command. If you don't want to change the commit message, you can add the --no-edit flag:
$ git commit --amend --no-edit
This will add the staged file to your last commit, without changing the commit message.
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
Changing the Last Commit Message
If all you want to do is to edit the message of your last commit, you can run the git commit --amend command without staging any new files:
$ git commit --amend
This will open your default text editor, allowing you to edit the message of your last commit.
After you've saved and closed the editor, the new commit message will be applied!
No Command Line Needed
Amending Commits in Tower
In the Tower Git client, amending a commit is very easy. You can right-click the commit in the history and choose "Amend [COMMIT HASH]...".
Even better, in the "Working Copy" view, you can hold down the Option key (on Mac) or the Alt key (on Windows) and the "Commit" button will turn into an "Amend" button.
Learn More
- Check out the chapter on Undoing Things – Desktop GUI edition in our free online book
Download the Cheat SheetFree
Get 18 of our most popular Cheat Sheets in one handy ZIP!

Thanks! Please Check Your Inbox!
Want to win one of our awesome Tower shirts?
Tell your friends about the package!
