`.gitignore` 文件中前导斜杠的含义
如果我将一个模式放入带有前导斜杠的 .gitignore 文件中,那么斜杠是指 .gitignore
文件所在的目录,还是指整个存储库的根?
(我找到的手册页仔细地隐藏了这些信息。)
If I put a pattern in a .gitignore
file with a leading slash, does the slash refer to the directory in which the .gitignore
file is located, or does it refer to the root of the whole repository?
(The man pages I have found have hidden this information carefully.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是文档文本:
这些是我的猜测:
如果您使用 in-repository-
.gitignore
,则.gitignore
所在的目录位于 - 使其相对于存储库根目录并不是真正有用。
在存储库根目录和子目录(以及
位于同一目录中的
.gitignore
)证实了这一点。如果您使用
.git/info/exclude
或core.excludesfile
,我认为它是相对的到存储库根目录。
此外,这(对于信息/排除)已通过同一测试(均在 1.7.3.4 上进行的测试)确认。
Schnouki 找到了有关此内容的文档的正确部分(强调我的):
可以说,为了清楚起见,这一事实可以在上面引用的后面部分中再次重复。
This is the documentation text:
These are my guesses:
If you use an in-repository-
.gitignore
, the directory in which the.gitignore
is located - it is not really useful to make it relative to the repository root.
A short experiment with same-named files in the repository root and a subdirectory (and a
.gitignore
in this same directory) confirms this.If you use an
.git/info/exclude
orcore.excludesfile
, I suppose it is relativeto the repository root.
Also this is (for info/exclude) confirmed by the same test (both tests on 1.7.3.4).
Schnouki found the right part of the documentation about this (emphasis mine):
One could say that this fact could have been repeated again at the later part quoted above, for clarity.