How to add items/changes to the previous Git commit

November 14, 2020

If you have made a git commit but realised you forgot something, you can easily update it with the git commit --amend command.

Examples of where you may want to use the git commit --amend command would be:

  • Update the latest git commit's log message
  • Update the previous commit's log title
  • Add another change to the most recent git commit
  • Add or remove a file from the most recent commit

All you have to do is make your changes to the files, then;

git add .; # or add the specific file(s) you want to add
git commit --amend;

If you want to only update the commit log message then you can skip the git add line and just run git commit --amend.