Git Amending a commit

Download Git for free


If your latest commit is not published yet (not pushed to an upstream repository) then you can amend your commit.

git commit --amend

This will put the currently staged changes onto the previous commit.

Note: This can also be used to edit an incorrect commit message. It will bring up the default editor (usually vi / vim / emacs) and allow you to change the prior message.

To specify the commit message inline:

git commit --amend -m "New commit message"

Or to use the previous commit message without changing it:

git commit --amend --no-edit

Amending updates the commit date but leaves the author date untouched. You can tell git to refresh the information.

git commit --amend --reset-author

You can also change the author of the commit with:

git commit --amend --author "New Author <>"

Note: Be aware that amending the most recent commit replaces it entirely and the previous commit is removed from the branch's history. This should be kept in mind when working with public repositories and on branches with other collaborators.

This means that if the earlier commit had already been pushed, after amending it you will have to push --force.

Amending the author of a commit