Getting following error/warning when I clone a large project in my Windows 10.
....
error: unable to create symlink Codes/MyProject/Pods/Headers/Public/nanopb/pb_common.h: No such file or directory
error: unable to create symlink Codes/MyProject/Pods/Headers/Public/nanopb/pb_decode.h: No such file or directory
error: unable to create symlink Codes/MyProject/Pods/Headers/Public/nanopb/pb_encode.h: No such file or directory
Updating files: 100% (9536/9536), done.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
Why the warning appears and how to resolve this?
However, I tried to run following command from the downloaded repo root directory as per gits suggestion,
git restore --source=HEAD :/
But again I got similar error like,
....
error: unable to create symlink Codes/MyProject/Pods/Headers/Public/nanopb/pb_common.h: No such file or directory
error: unable to create symlink Codes/MyProject/Pods/Headers/Public/nanopb/pb_decode.h: No such file or directory
error: unable to create symlink Codes/MyProject/Pods/Headers/Public/nanopb/pb_encode.h: No such file or directory
CodePudding user response:
Windows, by default, requires special privileges to create symlinks. This is because when Windows added symlinks, Microsoft was concerned that existing programs would acquire vulnerabilities due to symlinks that were already well known on Unix, and didn't want that to happen automatically. In retrospect, this has made symlinks extremely uncommon on Windows.
However, if you're using Windows 10 or newer, you can enable Developer Mode, which allows symlinks to be created by unprivileged users. I strongly recommend this because symlinks are very useful, but some people cannot do this because their system administrator hasn't allowed it. If this is possible in your case, it will fix the problem.
You can disable symlinks by setting core.symlinks
to false. Typically Git does this automatically when cloning a repository on a file system that doesn't support symlinks properly, so you shouldn't normally need to. Note that in many cases, the project will be broken in such a case, because the symlinks are typically present because they're required for things to work.
The other possibility here is that your project has two files or directories that differ only in case and Windows is case insensitive by default. As a result, what should be a symlink in one case is something like a file or directory in another case, and since your system is capable of handling only one case at a time, you can't check both out at once. This is just an unfortunate consequence of how Windows works by default, and you'll need to use an environment that is case sensitive, like Linux or WSL.
CodePudding user response:
The problem was solved using following command from Git bash,
git config --global core.symlinks false