Git symlinks on Windows: core.symlinks, mklink and Developer Mode
Codemia Knowledge Hub ·
Git records a symbolic link as a special entry (mode 120000) whose content is the target path, but whether it checks out as a real link on Windows depends on the filesystem, the user's privileges and the core.symlinks setting. The same committed symlink can appear as a real link on one Windows machine and as a plain text file containing the target path on another. Enabling Developer Mode and setting core.symlinks to true usually makes it work.
How Git stores a symlink
Git does not store a copy of the target file. It stores:
- a special file mode for symlink entries
- the target path as the blob contents
Unix-like systems recreate the symlink on checkout. On Windows, it depends on whether the environment can actually create symlinks.
What Windows needs to create symlinks
Windows supports symbolic links, but creating them historically required elevated privileges. On newer systems, Developer Mode makes it easier for normal development work. The deciding factors are:
- NTFS filesystem support
- whether the user can create symlinks
- whether Git believes symlinks are supported in that working tree
If these are not met, Git may fall back to a regular file that contains the link target as plain text.
The core.symlinks setting
Git uses core.symlinks to decide whether to check out symlinks as real symlinks. Check the current value:
Enable it for the repository if the machine supports symlinks:
This matters most when the repository is created or cloned on Windows, because Git probes the filesystem's capability at that point and may set the behavior accordingly.
Creating a symlink with mklink
From Command Prompt, create a file symlink with mklink:
For directories:
If symlink support is active, Git then sees a symlink entry:
If core.symlinks is disabled or the OS refuses to create the link, the result behaves differently.
Developer Mode
On modern Windows, enabling Developer Mode is often the easiest way to make symlinks usable without running every shell as Administrator. With it on, Git Bash, Command Prompt and PowerShell are much more likely to create and check out symlinks under normal user accounts. Without it, the repository may contain symlinks that the local checkout does not reproduce.
Cross-platform repositories
A repository shared across macOS, Linux and Windows can use symlinks, but only if Windows contributors have working symlink support. Otherwise they may see broken builds or odd text files where links were expected, so document the Windows prerequisites clearly.
To check how Git recorded an entry:
A symlink typically shows mode 120000, which confirms Git recorded it as a link in the index.
When to avoid symlinks on Windows
Avoiding symlinks can be the better choice when:
- contributors have locked-down corporate machines
- build tools do not handle symlinks consistently
- the repository is consumed by software that expects normal files only
Duplication, generated files or a different project layout may then be more reliable.
Why symlinks still break
- Symlink support is not purely a Git feature. On Windows, the OS and permissions matter just as much.
- If
core.symlinksis disabled, checkout can look wrong even when the repository stores the symlink correctly. - A Windows shortcut is not a symlink, and Git does not treat it as one.
- A symlink that works on one teammate's machine may not work on another, because Developer Mode, privileges and filesystem configuration differ.
Related reading
- Git tag before or after merge?
- git timezone and timestamp format
- git tries to delete a directory on checkout
- git undo all uncommitted or unsaved changes
- git undo all working dir changes including new files
- Git undo changes in some files
- Git undo local branch delete
- git update-index --assume-unchanged and git reset
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseInterview Questions practice on Codemia
Over 11,000 interview practice questions for 300+ companies, searchable by company and role.