Help, I forgot to add a file to my last commit
Add the missing file to the commit you just made, or follow up with a second commit if it is already pushed.
The fix
git add styles.cssStage the file you forgot.
git commit --amend --no-editFolds it into the last commit and keeps the message. Everything else that is staged goes in too.
styles.css is an example. Replace it with your own.
git add styles.cssStage the file you forgot.
git commit -m "Add missing styles"A small follow-up commit. Nothing is rewritten.
git pushA normal push, safe on any branch.
styles.css is an example. Replace it with your own.
Before
After
Why this works
--amend replaces your last commit with a new one that contains everything that is staged now, and --no-edit keeps the message. Because the commit is replaced, only do this before pushing. Once others may have it, a small follow-up commit is the honest and safe fix.