How to remove files from Git commit

Use the below command to change the position of HEAD of your branch.

git reset --soft HEAD^ 

or

git reset --soft HEAD~1

If you want to modify the content of the file. Edit the file directly. Alterantively if you want to remove the file from the commit then use below command.

git reset HEAD path/to/unwanted_file

Now commit again, you can even re-use the same commit message:

git commit -c ORIG_HEAD
Author

Vaibhav Bhootna

Posted on

2020-08-29

Updated on

2020-11-02

Licensed under

Comments