忽略git中具有相同名称的所有文件

时间:2012-01-24 02:52:40

标签: git gitignore

有没有办法让git ignore file忽略所有名称为test的文件?

我有这样的文件:

 - css/test.css 
 - js/subfolder/test.js 
 - lib/main/sub/test.html

等等。

我希望git避免添加或提交名称为test的任何文件。

4 个答案:

答案 0 :(得分:40)

来自git docs

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".

对于你的情况:

**/[Tt]est*

它也匹配大写和小写。

答案 1 :(得分:24)

使用.gitignore

更新test*

另外,请阅读this以获取更多信息。

答案 2 :(得分:4)

尝试将模式添加到test。*

的.gitignore

添加它并使用上面提到的一些文件执行git状态。

如果它有效,那就很好。

答案 3 :(得分:0)

这些解决方案都不适用于我的情况,我无法摆脱一堆Iconr文件。但是,有another question专门针对此问题,其中the answer that worked for me是将此行添加到.gitignore

Icon?
相关问题