Jacob Petersen
Jacob Petersen

Reputation: 47

Windows changes symlink file when cloned from repo

I have a git repository that contains some symlinks. This is usually used in a Linux environment.

However, when the repo is cloned to windows one of the symlinks changes, and thus building on windows using docker does not work.

The problem is quite simple. I have a symlink as such: localtime -> /etc/localtime

But when the file is cloned to a windows system it changes to : localtime -> c:/etc/localtime

This breaks the symlink when I try to make a build with it, as such building from windows doesn't work. The symlink in my Linux build will have changed to /c/etc/localtime instead of /etc/localtime

Git also doesn't seem to even register this change, as git status says all the files are up to date with master, even though this file is clearly different from the one in the repo

Is there any way to stop windows from automatically changing this file when its cloned?

Or is changing it to a be relative path the only option?

Upvotes: 1

Views: 202

Answers (1)

StPiere
StPiere

Reputation: 4243

You could remove a symlink from index and add a script (bash, python or whatsoever) instead which generates a symlink.

Either you run this script by hand after clone or create a hook. Git handles text files much better as any other files, including symlinks.

If you use docker build, then you could setup to run this symlink-creation-step after clone anyway.

Upvotes: 1

Related Questions