I have a folder on a Windows Server 2019 build agent, we'll call Machine A. I create a symbolic link on NTFS in that folder that points to a folder on another remote machine, we'll call Machine B.

When checking out the git repository, I check it out and specify the symbolic link as the folder I'd like to check it out into (which is empty on Machine B).

However, the error I get is, fatal: failed to stat <insert symbolic link path here> Permission denied

Git then proceeds to delete the folder, and check it out to the folder non-linked.

Since Git obviously has permissions to write in the working folder on Machine A, my first thoughts were to use Powershell, grab the ACL of the working folder on Machine A, and overwrite the symbolic links ACL with working folder's ACL.

That didn't work, any ideas?


You haven't mentioned which operating system you're on, but by the mention of NTFS, I'll assume it's Windows.

Git needs the ability to call the equivalent of the stat(2) function on your symbolic link, since it needs to know if (a) it's a folder and (b) if it's empty. If it's not both of those things, it should print an error and fail instead of letting you clone into it.

On Windows, the equivalent function is GetFileAttributesExW, and according to the Git source code, you're getting one of ERROR_ACCESS_DENIED, ERROR_SHARING_VIOLATION, ERROR_LOCK_VIOLATION, or ERROR_SHARING_BUFFER_EXCEEDED. Essentially, you lack some sort of permission to read the metadata about that link, or there's some sort of sharing problem.

If you figure out what that issue is, it's likely that Git will work for you, since this does work on Unix systems. However, Microsoft doesn't document what a particular error means for a given function, so you're left to figure it out for yourself. You can try to make sure you have adequate permissions on the parent directory of the link and on the destination (remote) folder as well. Note that you will likely require the equivalent of the Unix read and search permissions in addition to write permission.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.