0 votes
1 view
in Devops and Agile by (19.5k points)

Our developers use a mix of Windows and Unix based OS's. Therefore, symlinks created on Unix machines become a problem for Windows developers. In windows (msysgit), the symlink is converted to a text file with a path to the file it points to. Instead, I'd like to convert the symlink into an actual Windows symlink.

The (updated) solution I have to this is:

Write a post-checkout script that will recursively look for "symlink" text files.

Replace them with windows symlink (using mklink) with same name and extension as dummy "symlink"

Ignore these windows symlink by adding an entry into .git/info/exclude

I have not implemented this, but I believe this is a solid approach to this problem.

Questions:

What, if any, downsides do you see to this approach?

Is this post-checkout script even implementable? i.e. can I recursively find out the dummy "symlink" files git creates?

Has anybody already worked on such a script?

1 Answer

0 votes
by (33.8k points)

To find the symlinks you all need to look for files having a mode of ‘120000’  because the documentation says that: 

If you’re specifying a mode of 100644, which means it’s a normal file. Other options are 100755, which means it’s an executable file; and 120000, which specifies a symbolic link.

Reference: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects

For this question you need to look for the files using:

git ls-files -s | awk '/120000/{print $4}'

And after changing this I would like to suggest you mark them as unchanged using:

git update-index --assume-unchanged

Rather than listing them in .git/info/exclude file.

...