2012-01-24 126 views
22

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

我有这样的文件:

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

等。

我想git,以避免添加或提交任何名称测试文件。

+0

这个问题和许多其他您可能对gitignores可以通过读取'人gitignore',其中包含的说明来回答的语法和一些小例子。 – Cascabel

回答

21

更新.gitignoretest*

此外,对于更多的信息,请阅读this

4

尝试添加模式的.gitignore测试。*

添加它,做一个git地位的一些文件,比如你上面提到。

如果它工作,你很好。

18

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* 

它也同时匹配大写和小写。

0

这些解决方案都不适用于我的情况,我无法摆脱一堆Iconr文件。然而,another question,专门用于解决这一点,在那里the answer that worked for me是加入这一行的.gitignore

Icon? 
+0

这个问题是关于忽略文件,另一个是关于从存储库中删除它,这些是不同的主题。也许[这个问题](https://stackoverflow.com/questions/17556250/how-to-ignore-icon-in-git)更相关 –

相关问题