Ignoring symlinks in git

2019-02-21 15:03发布

问题:

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).

回答1:

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.