Tip
Git: Amend Last Commit
Forgot to include a file in your last commit? No need to create a new commit.
# Stage the forgotten files
git add forgotten-file.txt
# Amend the last commit
git commit --amend --no-edit
The --no-edit flag keeps the original commit message. If you want to change the message, just run git commit --amend without the flag.
Warning: Only amend commits that haven’t been pushed yet, or you’ll need to force push.