一种验证.gitignore文件的方法 [英] A way to validate .gitignore file
问题描述
有没有一种方法可以验证.gitignore文件,以便您快速找到double路径或不再存在的路径?通常,当一个项目很小时,这并不是真正必要的,但是由于很多分支和.gitignore文件的合并,这可以在手.
Is there a way to validate a .gitignore file so you quickly find doubles paths or paths that don't exist anymore? Normally when a project is small this isn't really necessary but with lots of branches and mergings of .gitignore files this can come in hand.
推荐答案
不完全是.
一个可能接近的命令是 git check-ignore
Not exactly.
One command which could come close would be git check-ignore
选择一个您应该忽略的文件,然后检查以下内容的输出:
Choose a file you know is supposed to be ignored, and check the output of:
git check-ignore -v -- /path/to/ignored/file
您将看到.gitignore
的适用规则.
2016年3月更新:Git 2.8将添加一种调试.gitignore
文件及其规则的新方法.
Update March 2016: Git 2.8 will add a new way to debug .gitignore
files and their rules.
在允许子文件夹不被忽略的情况下(即使其父文件夹被忽略),请参见:此宝石,它是 href ="https://github.com/pclouds" rel ="noreferrer">吴恩达(pclouds
):
In the context of allowing a sub-folder to not be ignored (even if its parent folder is ignored: see example here), I have found this gem by Thái Ngọc Duy (pclouds
):
dir.c
:支持跟踪排除
dir.c
: support tracing exclude
man git
包括:
GIT_TRACE_EXCLUDE:
启用有助于调试
.gitignore
处理的跟踪消息.
有关可用跟踪的信息,请参见'GIT_TRACE
'输出选项.
Enables trace messages that can help debugging
.gitignore
processing.
See 'GIT_TRACE
' for available trace output options.
将GIT_TRACE_EXCLUDE
设置为1,您将看到(在git status
之后)标准调试器调试消息,例如:
With GIT_TRACE_EXCLUDE
set to 1, you will see (after a git status
) stderr debug messages like:
exclude: from ...
exclude: xxx => n/a
exclude: xxx vs. yyy at line z: => www
这篇关于一种验证.gitignore文件的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!