Add a forgotten file to the last commit
Careful: rewrites history
Short answer
Stage the file, then run git commit --amend --no-edit. The last commit now includes it, with the same message.
Like any amend, this replaces the last commit. Only do it before you push.
The commands, one by one
- 1
git add muffins.txtStages the file you forgot.
- 2
git commit --amend --no-editRebuilds the last commit with what's staged now.
--no-editkeeps the commit message as it was.
For your own repository: Use your own file name in git add.