Remove files from Git commit

Ask a question+

I am using Git and I have committed few files using

git commit -a

Later, I found that a file had mistakenly been added to the commit.
How can I remove a file from the last commit?

add comment

1 Answer


git reset —soft HEAD^
Then reset the unwanted files in order to leave them out from the commit:

git reset HEAD path/to/unwanted_file

add comment

Your Answer