Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git checkout -- <filename> doesn't recover a locally deleted symbolic link on Windows 10

So, yes, I am using Windows 10, when everyone around me at the office is using Linux/Mac. But I won't give up.

I deleted a Symlink which is part of the repo, that was locally created by "git clone" - (Read below why if you are bored)

Now when I run "git status" it says : "Deleted" for my symlinks. I want them back, so I tried the following :

git checkout .
git checkout --
git reset --hard HEAD

Nothing worked, they all completed without errors, but "git status" still shows the symlinks are deleted, and indeed "ls" shows they are gone. Any attempt to create them myself using "ln -s" (in git-bash) results in "typechange" in git status.

How can I get "git checkout ." or any other git command to restore the symlinks to be as they are in the repository?

like image 435
eitama Avatar asked Nov 29 '25 04:11

eitama


1 Answers

So, yes, the timestamp should reveal I posted the question when I already knew the answer, but, as I spent almost two hours trying to resolve this, and the answer is not on stackoverflow (yet) I decided I shell post my question anyway and answer it.

Eitam@DESKTOP-JJOOD64 MINGW64 /d/git/my-repo (master)
$ git checkout .

Eitam@DESKTOP-JJOOD64 MINGW64 /d/git/my-repo (master)

The command seems to have completed with no errors or problems, but "git status" will still show my symlinks are not there.

The solution :

run git-bash as Administrator!!! and use "git checkout ." or "git reset --hard HEAD" or any git command that was supposed to work in the first place.

It's quite annoying that git-bash didn't complain that it's missing Administrator privileges. I found out that it's needed when I tried to work around the problem by creating the symlinks myself using "mklink" which told me I need admin priv...

like image 131
eitama Avatar answered Nov 30 '25 19:11

eitama