Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i commit a windows symlink into Git

I have added a windows (window 7) symlink to my codebase ("foo" -> \\server\foo). I have a large set of configuration files under the networks share -\server\foo location. How do i check-in this symlink "foo" into my Git repo?

Any other user cloning the repo should get this link and should be able to pick up the files from the \\server\foo\ location.

The thought is to avoid repeated syncs of this large set of config files during integration builds

When i tried checking in, all the files under the \\server\foo location. When a user cloned the repo, "foo" was added as a simple directory.

like image 279
praskris Avatar asked Nov 07 '13 20:11

praskris


People also ask

Does Git support symlinks on Windows?

Git for Windows does not support symlinks, which replaces with text files containing the path to the linked entry.

Can you add symlinks to Git?

Git can track symlinks as well as any other text files. After all, as the documentation says, a symbolic link is nothing but a file with special mode containing the path to the referenced file. Knowing how to handle links is the OS job.

Can you create symlinks in Windows?

On Windows 10, you can set up symlinks through the Command Prompt using the mklink command. First up, launch the Command Prompt by typing cmd in the Start menu search bar, then right-click the Best Match and select Run as administrator. You can use the mklink command to create hard and soft links.

How do you create a relative path in a symbolic link?

Relative Symbolic Link : An relative symbolic link is an symbolic link, whose target has relative path. An relative path is path that is based on Current Working Directory. The path of target file/folder will be calculated according to the current path of symlink. Therefore, there is no definite path so as to say.


1 Answers

You need to create the right entries (special filemode 120000) in the index in order to encode, and then decode symlinks in Windows.

See "Git Symlinks in Windows", espcially the aliases

  • git add-symlink
  • git checkout-symlinks
like image 118
VonC Avatar answered Oct 30 '22 19:10

VonC