git 忽略git中所有同名文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8981472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ignore all files with the same name in git
提问by Chapsterj
Is there a way to have a git ignore file
to ignore all files with the name test in them?
有没有办法让 agit ignore file
忽略其中包含名称 test 的所有文件?
I have files like this:
我有这样的文件:
- css/test.css
- js/subfolder/test.js
- lib/main/sub/test.html
and so on.
等等。
I want git
to avoid adding or committing any files with the name test.
我想git
避免添加或提交任何名称为 test 的文件。
采纳答案by James Raitsev
回答by Alex.K.
From git docs
来自git 文档
A leading "**" followed by a slash means match in all directories. For
example, "**/foo" matches file or directory "foo" anywhere, the same
as pattern "foo". "**/foo/bar" matches file or directory "bar"
anywhere that is directly under directory "foo".
For your case:
对于您的情况:
**/[Tt]est*
it also matches both upper and lower case.
它还匹配大小写。
回答by Dave G
Try adding the pattern to .gitignore of test.*
尝试将模式添加到 test.gitignore 中。*
Add it and do a git status with some files like you mentioned above.
添加它并使用上面提到的一些文件执行 git status 。
If it works you're good.
如果它有效,你就很好。