I a trying to delete the last commit from the local repository by using the
git reset --hard HEAD~1
command. However I get the following error:
fatal: Could not reset index file to revision 'HEAD~1'.
I get
(Filename too long)
for several files. How can I avoid this? I am on Windows
To hard reset files to HEAD on Git, use the “git reset” command with the “–hard” option and specify the HEAD. The purpose of the “git reset” command is to move the current HEAD to the commit specified (in this case, the HEAD itself, one commit before HEAD and so on).
The git reset HEAD~2 command moves the current branch backward by two commits, effectively removing the two snapshots we just created from the project history. Remember that this kind of reset should only be used on unpublished commits.
Try to see if those error persists with:
git config --system core.longpaths true
Make sure to use the latest git-for-windows (2.7.0), and you should not even need that option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With