2013-01-12 14 views
6

我嘗試這樣做的.gitignore文件點:的Git:不要忽視一個-directory-在它

* 
!mydirectory.ext 
!.gitignore 

但它不工作,除了gitignore一切都將被忽略。

也試過:

!\mydirectory\.ext 

目錄需要擴展,因爲它的一個插件的應用程序。

任何解決方法?

+0

所以,你真的想忽略_everything_除了那個目錄嗎? – fge

回答

2

那些種白名單不是混帳容易成爲可能。

一旦你忽略了一個目錄,git不會查看它的內部,因此不會檢查這個目錄內的異常。

要解決這個問題的唯一方法是長期包含/排除級聯,這是非常醜陋的。

最好的方法是再次考慮您的問題,並嘗試在沒有這種一般例外情況下解決問題,例如明確忽略您確定不需要的所有內容。

7

ref

* 
!/mydirectory.ext/ 
!/mydirectory.ext/* 
!/mydirectory/.ext/ 
!/mydirectory/.ext/* 
!.gitignore 

* 
# ignore all 
!/.*/ 
# but not directories which names starting with a dot 
!/.*/* 
# and all its contents 
/.*/*/ 
# but ignore other directories (which names not starting with a dot) 
# which results also not tracking its files underneath 
!/.*/.*/ 
# but not to subdirectories (which names starts with a dot) 
!/.*/.*/* 
# and its contents 


!/*.*/ 
# don't ignore directories which names has a dot in it 
!/*.*/* 
# and its contents 
# extend it like with /.*/ 
!.gitignore