Question:
In last hour or so i have modified files
1 2 3 4 5 |
A ATest B BTest |
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:
- Revert previous commit without affecting my currently uncommitted files?
- Add another file under the same description to the previous commit?
Answer:
To add a new file to the previous commit:
1 2 3 |
$ git add new-file $ git commit --amend |
You can use git commit --amend --no-edit
if you don’t want to change the commit message.