2013-09-30 121 views
1

以下多個子目錄我有一個問題,對於gitignore異常語法(!FILENAME.TXT)時,該文件是被忽略的目錄下的多個子目錄是行不通的。混帳忽略例外不工作忽略目錄

例如:

web/[Ee]xample.[Ww]eb/[Ss]itecore/* 
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32* 

不包括在文件夾32×32的文件。
我通過命令行來手動添加像這樣:

git add -f -r web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32 

是否有使用異常操作在這樣的情況呢?

+0

又是什麼** ['git的入住ignore'(http://stackoverflow.com/a/18953923/6309)**說?什麼實際的忽略規則適用或不適用? – VonC

+0

我試圖做在bash的git的檢查,忽略和它說沒有找到命令。 –

+0

這是一個相當新的命令。你使用的是什麼git版本? – VonC

回答

1

再包括一個文件「是多個子目錄下忽略目錄」(當你嘗試),不起作用,因爲「這是不可能再有一個文件,如果該文件的父目錄中排除」 [source]。

作爲一個醜陋的,但是,工作的解決方法,再包括重新包括您需要的文件,同時保持在這些父目錄中的文件通過了再排除之前路徑上所有的父目錄。

對於您的例子,它希望如下:

web/[Ee]xample.[Ww]eb/[Ss]itecore/* 

!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/ 
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/** 
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/ 
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/** 
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/ 
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/** 
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/ 
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/** 
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32* 

來源:我的答案相關here

另外,你也可以使用的.gitignore被放置在文件的目錄中的文件重新包括[more here。根據口味,這可能是更漂亮的解決方案。