Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when trying to reset git HEAD

Tags:

git

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

like image 603
luca.p.alexandru Avatar asked Jan 22 '16 14:01

luca.p.alexandru


People also ask

How do you force a head reset?

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).

What is git reset HEAD command?

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.


1 Answers

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.

like image 94
VonC Avatar answered Nov 15 '22 04:11

VonC