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.

praskris
  • 479
  • 5
  • 15
  • 2
    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. – Eevee Nov 07 '13 at 22:07
  • @Eevee - 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 :( – praskris Nov 08 '13 at 16:52
  • Creating symlinks on Windows still doesn't work natively, even as of [Git for Windows v2.3.6.](https://github.com/git-for-windows/git/issues/117). – Dan Dascalescu Apr 27 '15 at 08:18

1 Answers1

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
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 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\ – praskris Nov 08 '13 at 16:41
  • @praskris can't you `subst` that network path, associating it to a drive letter? – VonC Nov 08 '13 at 16:41
  • 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. – praskris Nov 08 '13 at 16:49
  • 1
    @praskris then the question isn't really about git and symlinks, but more about Windows symlinks and UNC path, isn't it? – VonC Nov 08 '13 at 18:22
  • @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 too – praskris Nov 08 '13 at 20:33
  • @praskris 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. – VonC Nov 08 '13 at 21:20