2012-01-24 129 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)更相關 –

相關問題