Andres Riofrio Andres Riofrio - 1 year ago 158
Git Question

What happens when I clone a repository with symlinks on Windows?

There's been a lot of questions about adding support for symlinks on Windows. But, what actually happens when I clone a repository with symlinks on Windows?

Answer Source

Since version 1.5.3 of the native Git client git clone and git init will probe the target file system for symlink support and set the local repository configuration for core.symlinks accordingly, i.e. to false for FAT or NTFS. This makes e.g. symlinks created under Linux to be created as plain text files that contain the link text under Windows (see the git config documentation on core.symlinks for details).

Since Git for Windows version 2.10.2 the installer has an explicit option to enable symbolic link support.

In older versions of Git for Windows you can manually set core.symlinks to true which enabled Git to create symbolic links under the following constraints:

  • Symbolic links are only available on Windows Vista and later.
  • Symbolic links will only work on NTFS, not on FAT.
  • You need to be an admin and / or have the SeCreateSymbolicLinkPrivilege privilege.
  • Symbolic links on remote filesystems are disabled by default.
  • Windows' symbolic links are typed.
  • Many programs do not understand symbolic links (that includes older version of Windows Explorer).

More details are available in the Git for Windows wiki.

In older versions of Git for Windows manually setting core.symlinks manually to true after cloning and reset your working tree, you would get error messages similar to

$ git reset --hard HEAD
error: unable to create symlink directory (Function not implemented)
error: unable to create symlink linux-links/this_is_a_symbolic_link_to_file (Function not implemented)
fatal: Could not reset index file to revision 'HEAD'.

As a side note, the JGit client did not probe the target file system for symlink support until its version 3.3, so the core.symlinks setting was falling back to whatever the system / global Git configuration was. Starting with version 3.3 JGit probes for symlink support but seems to be too conservative, setting core.symlinks = false in some cases where symlinks would be in fact supported.

You can checkout which contains a bunch of links created on Linux for testing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download