How can I add a file to the last commit in Git? [duplicate]

Yes, there’s a command, git commit --amend, which is used to “fix” the last commit.

In your case, it would be called as:

git add the_left_out_file
git commit --amend --no-edit

The –no-edit flag allows to make an amendment to the commit without changing the commit message.

Warning

You should never amend public commits that you already pushed to a public repository, because amend is actually removing the last commit from the history and creating a new commit with the combined changes from that commit and new added when amending.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)