问题描述
我有两个我希望忽略的文件:
- .idea / workspace.xml
- someapp / src / .idea / workspace.xml
我认为将这一规则添加到.gitignore就足够了:
.idea / workspace.xml
但它仅捕获顶级.idea / workspace.xml(git status显示someapp / src / .idea / workspace.xml为未跟踪)。
** /。idea / workspace.xml ,但是这根本不起作用。帮助?
只要路径包含斜线,Git就不会再检查匹配的路径,而是直接使用glob行为。因此,您无法匹配 .idea / workspace.xml
,但仅适用于 workspace.xml
。
I have two files I wish to ignore:
- .idea/workspace.xml
- someapp/src/.idea/workspace.xml
I thought adding this single rule to .gitignore will suffice:
.idea/workspace.xml
But it only catches the top-level .idea/workspace.xml (git status shows someapp/src/.idea/workspace.xml as untracked).
I also tried **/.idea/workspace.xml
, but this doesn't work at all. Help?
As soon as the path contains a slash, Git will no longer check for a match in the path but instead will use the glob behaviour directly. As such, you cannot match for .idea/workspace.xml
but only for workspace.xml
.
这篇关于为什么gitignore在这种情况下工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!