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
# GIT

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×