git – How to add file to a previous commit?


In last hour or so i have modified files

In order to make sure my commit messages line up with the actual change, committed A with a description. Unfortunately i have not included ATest into that commit.

Meanwhile, still not committed are B and BTest.

What is the best way to proceed at this point? I’d like to either:

  1. Revert previous commit without affecting my currently uncommitted files?
  2. Add another file under the same description to the previous commit?


To add a new file to the previous commit:

You can use git commit --amend --no-edit if you don’t want to change the commit message.

Leave a Reply