How do i commit a windows symlink into Git
Asked Answered
O

1

13

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.

Ovum answered 7/11, 2013 at 20:5 Comment(3)
i don't know for sure, but i somewhat doubt git understands windows links, being written by the linux kernel's author for use with the linux kernel and all. even putting unix symlinks in git isn't the greatest idea.Lepton
@Lepton - I suspect the same as well. However, there is about 80 -90mb content in this symlinked folder. I do not wish to have that committed to the repo and downloaded everytime for a CI build. The firm has a CI standard where a fresh sync is done for every build and that standard cannot be altered :(Ovum
Creating symlinks on Windows still doesn't work natively, even as of Git for Windows v2.3.6..Jeffers
V
6

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
Vertumnus answered 8/11, 2013 at 7:40 Comment(6)
This doesnt work for me, not sure if i am missing something. From the example I see that they are usign a link for a directory within the structure. However, my usecase is to create a symlink for a folder in a network share. bla -> \\server\foo\Ovum
@Ovum can't you subst that network path, associating it to a drive letter?Vertumnus
unfortunately I cannot as the code is synced to different agents and directories during continuous integration builds and subst (ing) the folder into the specific location in the structure will not be possible. Moreover, we might not have the permission to do that int he build agent machine.Ovum
@Ovum then the question isn't really about git and symlinks, but more about Windows symlinks and UNC path, isn't it?Vertumnus
@VonC- I am not sure I understand. I am able to create a symlink to a UNC path in windows. Thr problem is with committing it to Git. It picks it up as a normal folder and adds all the files under the symlinked folder tooOvum
@Ovum then my answer stands, as it convert any symlink into an 120000 index entry, or convert that 120000 entry back to a symlink. (the checkout-symlinks). If you say you are able to create a symlink to UNC path, all you need to do is to make sure the checkout-symlinks alias does the same command.Vertumnus

© 2022 - 2024 — McMap. All rights reserved.