我有两个我想忽略的文件:
我认为将这条规则添加到.gitignore就足够了:
.idea/workspace.xml
Run Code Online (Sandbox Code Playgroud)
但它只捕获顶级.idea/workspace.xml(git status显示someapp/src/.idea/workspace.xml为未跟踪).
我也尝试过**/.idea/workspace.xml
,但这根本不起作用.救命?
edd*_*ves 21
使用平台fnmatch(3)函数(许多地方,如pathspec匹配,.gitignore和.gitattributes)已被wildmatch取代,允许"foo/**/bar"匹配"foo/bar","foo/a/bar" "等
**/.idea/workspace.xml
现在应该在这个例子中工作.
pok*_*oke 11
- [...]
- 如果模式不包含斜杠/,git将其视为shell glob模式,并检查相对于.gitignore文件位置的路径名的匹配(相对于工作树的顶层,如果不是来自.gitignore)文件).
- 否则,git将模式视为适合fnmatch(3)使用FNM_PATHNAME标志的shell glob:模式中的通配符与路径名中的/不匹配.[...]
一旦路径包含斜杠,Git将不再检查路径中的匹配,而是直接使用glob行为.因此,您无法匹配.idea/workspace.xml
但仅适用于workspace.xml
.
请参阅gitignore手册中的示例:
"Documentation/*.html"匹配"Documentation/git.html"但不匹配"Documentation/ppc/ppc.html"或"tools/perf/Documentation/perf.html"
所以.idea/workspace.xml
将匹配根目录但不匹配someapp/src/.idea/workspace.xml
但是根据你的fnmatch实现,这是你的.gitignore所需要的:
.idea/workspace.xml
**/.idea/workspace.xml
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13621 次 |
最近记录: |