Use mklink in msys

Using cmd //c mklink directly on the MSYS bash command line should work.

$ cmd //c mklink
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

Note: The mklink command and arguments need to be provided as a single argument to cmd. Quote the entire command like so

cmd //c 'mklink link target'

Note that the command would normally be

cmd  /c 'mklink link target'

which would work in Cygwin and other shell environments, and even in an existing CMD session.  However, msys seems to mangle command-line arguments (to Windows commands), and it interprets /c as a pathname to the root of the C disk, and converts it to c:\.  Typing //c has been found to cause msys to pass the /c option to cmd.  See How to run internal cmd command from the msys shell?


You can use Windows native symlinks. To enable it uncomment line with:

MSYS=winsymlinks:nativestrict

in MSYS2 start bat file. And run MSYS2 with admin privileges.


Windows 10 now supports symbolic links without needing to run as administrator, so long as you turn on developer mode in the Windows settings.

Once that is done, you can get ln working correctly with a single line in a .bashrc file in your home directory!

export MSYS=winsymlinks:nativestrict

(I was not able to figure out where the equivalent .ini file is in my Git Bash installation. But setting the environment variable there would probably work, too.)

More details in this very helpful article by Josh Kelley: https://www.joshkel.com/2018/01/18/symlinks-in-windows/