2016-01-28 39 views
1

我有動態的目錄結構類似,gitignore文件模式不工作

dependency 
    a 
    b 
    c 
    d e 
    f 
    g 
     h 

我想忽略遞歸的依賴文件夾下的所有文件,除了.xml文件。

我正在使用以下模式來實現相同。

dependencies/** 
!dependencies/**/*.xml 

但現在看來,這不是爲我工作。它忽略所有文件,但只接受.xml文件,這些文件是直接裏面的依賴文件夾,不遞歸。 :(

我使用下面的環境
OS:Windows 7中(64位)
混帳:2.6.1.windows.1

誰能幫我

+0

背後有根本原因,有一些規則,而**不包括**或**重新包含**文件。請參閱:http://git-scm.com/docs/gitignore#_notes –

回答

1

這應該工作:

你忽略一切,但白名單父文件夾。
然後你可以白名單文件。

dependencies 
!dependencies/**/ 
!dependencies/**/*.xml 

正如我在 「How do I add files without dots in them (all extension-less files) to the gitignore file?」 中提到,主要是有一個規則與.gitignore要記住:

It is not possible to re-include a file if a parent directory of that file is excluded.

這意味着,當你排除一切( '*'),你有在白名單文件夾之前,能夠白名單文件。

檢查這是否與git check-ignore -v -- afile一起使用,看它是否被忽略(以及按照哪個規則)。