🔗Git for Windows vs symbolic links

Short version: there is no exact equivalent for POSIX symlinks on Windows, and the closest thing is unavailable for non-admins by default unless Developer Mode is enabled and a relatively recent Windows 10 version is used. Therefore, symlink emulation support is only turned on by default when that scenario is detected. Support can be enabled by the user, via the core.symlinks=true config setting.

🔗Background

Starting with Windows Vista, there is support for symbolic links. These are not your grandfather’s Unix symbolic links; they differ in quite a few ways:

For those reasons, Git for Windows disables support for symbolic links by default (it will still read them when it encounters them). You can enable support via the core.symlinks config variable, e.g. when cloning:

git clone -c core.symlinks=true <URL>

By default, the ln -s command in Git Bash does not create symbolic links. Instead, it creates copies.

To create symbolic links (provided your account has permission to do so), use the built-in mklink command, like so:

mklink /d this-link-points-to c:\that-directory
mklink this-link-points-to c:\that-file

The privilege of Create symbolic links can be assigned using local policy editors (or via policies from Active Directory in case of domain accounts). Home Editions of Windows do not have these policy editors, but the freely available Polsedit can be used on these editions.

Note that regardless of privilege assignment, members of the Administrators group will also require UAC elevation (see the full details in the Access Token Changes section in this document on UAC). Since Windows 10 version 1703 (Creators Update), enabling Developer Mode will disable this restriction and allow creating symlinks without UAC elevation (although Git for Windows still requires UAC elevation up to and including v2.13.0).

🔗Creating directory junctions

Directory junctions can be created by non-administrator users by default. Therefore, they are a popular alternative to symbolic links. To create a directory junction, use the mklink command with the /j option:

mklink /j this-link-points-to c:\that-directory