windows 忽略 git 中的符号链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5190170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:20:01  来源:igfitidea点击:

Ignoring symlinks in git

windowslinuxgitsymlinkshortcut

提问by Jason Gross

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?

有没有办法让 git 完全忽略符号链接(将它们留在树中,但不在结帐时创建它们)?或者,有没有办法让 git 在 linux 上的符号链接和 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).

上下文:我在 windows 和 linux 上都使用 git 和一些 LaTeX 文件。在 linux 上,我在 repo 之外存储了大量样式文件,并从一堆地方符号链接到。如果 git 将它们转换为 Windows 上的快捷方式(我具有相同的周围目录/文件结构),或者如果 git 完全忽略它们并且不检查它们(我的 LaTeX 发行版中的样式文件在视窗)。

回答by VonC

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

在“忽略符号链接”方面,您可以将配置core.symlinks配置变量设置为false(作为 Windows Git 存储库中的本地配置):

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.

符号链接将被检出为小的纯文本文件,其中包含它链接到的文件系统对象的路径,但不创建所述目标对象。