我有一个中央.gitignore
在我的笔记本电脑上,对于我创建的每个项目,我都会创建一个指向该中央文件的符号链接(symbolic link),以便我可以在所有项目中保持统一的策略。
我所有的项目都彼此相似(技术方面),拥有一个中心 .gitignore
是有意义的以减轻维修负担。
但是,最近我看到这条消息:
warning: unable to access '.gitignore': Too many levels of symbolic links
当我搜索时,似乎从 git 2.3 开始,他们决定不支持符号链接(symbolic link)。
我有两个问题。首先,有没有办法强制 git 支持
.gitignore
的符号链接(symbolic link)? ?为什么他们不再支持它了?重用代码没有意义吗?有一半的linux没有通过符号链接(symbolic link)重用吗?
最佳答案
First, is there a way to force git to support symbolic links for
.gitignore
?
不。
And why on Earth do they not support it anymore?
The gitattributes documentation接近尾声时说:
NOTES
Git does not follow symbolic links when accessing a
.gitattributes
file in the working tree. This keeps behavior consistent when the file is accessed from the index or a tree versus from the filesystem.
虽然我自己并不是 100% 相信这里的推理,但它确实是有道理的。 (在我看来,Git 可以将
.gitattributes
文件的内容填充到索引中并因此填充到提交中,尽管这意味着在 checkout 时它会破坏符号链接(symbolic link)。)
关于linux - 有没有办法仍然为.gitignore 使用符号链接(symbolic link)?为什么不再支持它作为符号链接(symbolic link)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72729555/