13

Is there a way to make git completely ignore symlinks (leave them in the tree, but not create them on checkout)? Alternatively, is there a way to make git convert between symlinks on linux and shortcuts on windows?

Context: I'm using git with some LaTeX files on both windows and linux. On linux, I have a large number of style files stored outside the repo, and symlinked to from a bunch of places. It'll work fine if git turns them into shortcuts on windows (I have the same surrounding directory/file structure), or if git ignores them completely, and doesn't check them out (I have the style files in my LaTeX distribution on windows).

Jason Gross
  • 5,928
  • 1
  • 26
  • 53
  • possible duplicate of [Ignore symbolic links in .gitignore](http://stackoverflow.com/questions/3511312/ignore-symbolic-links-in-gitignore) – dgw Jul 26 '12 at 08:09

1 Answers1

6

On the "ignoring symlink" side, you could set the config core.symlinks configuration variable to false (as a local config within the Windows Git repo):

Symlinks would be checked out as small plain text files that contain the path of the file system object that it links to, but without creating said target object.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 3
    If I'm ignoring symlinks, then I want the files by that name to not appear. Having small text files by the name of the symlink breaks LaTeXing. – Jason Gross Mar 06 '11 at 04:03
  • 1
    @Jason: then I can only see a post-checkout hook moving all those files out of the way, plusupdating the index to "assume-ignore" them (in order to not detect the fact they are missing): http://stackoverflow.com/questions/4633681/git-ignoring-version-controlled-files – VonC Mar 06 '11 at 09:49
  • 1
    Do post-checkout hooks get called on, e.g., `git reset --hard`? – Jason Gross Apr 06 '11 at 09:53
  • @Jason: don't sure, but I don't think so (http://stackoverflow.com/questions/3639342/whats-the-difference-between-git-reset-and-git-checkout) – VonC Apr 06 '11 at 12:52
  • 1
    Even worse, I have a similar problem, but I might have symlinks with the same name in repos on two different computers, but pointing to different places. A post-checkout hook won't work with that setup, will it? – naught101 May 29 '12 at 06:01
  • @naught101 it could help if the goal of that post-checkout hook is just to get rid of those symlink files. – VonC May 29 '12 at 06:03