I have committed a change and forgot to add a file to the change set. After other commits, I realized the file is now missing from a HEAD^4
commit.
How do I
I realize people can google and come here to find a simpler answer: What if it was just the last commit? (OP's question is for fixing the 4th commit back in history)
In the case you commit and realize you forgot to add some file immediately, just do:
# edited file-that-i-remember.txt
git add file-that-i-remember.txt
git commit
# realize you forgot a file
git add file-that-i-forgot.txt
git commit --amend --no-edit
Where --no-edit
will keep the same commit message.
Easy peasy!