Git is the most popular source code management tool. If you are new to the git I would recomment you to go through the complete Git turorial.
In this turorial I’m going to share simple trick to reset or remove file from git commit. Let’s see.
I’m sure you will find this simple command very handy and useful while working on projects.
How to remove files from git commit?
If you have added any unwanted or wrong files to the git commit, no worries. This happens and we do make mistakes. You can remove any file that has been added to the commit.
Use git reset command where you have to provide filename with complete directory path.
git reset HEAD path/to/file
Note: This command will not work if you have already pushed the code to your repository. It means you can not revert the chnages once changes are already pushed. In that case, you have to revert the git commit.
Any query? Let me know in the comment section below.