2014-02-28 51 views
1

我正在創建我的點文件並使用哦我的zsh。它會在我的主目錄中創建一個名爲.oh-my-zsh的目錄。忽略子目錄的.gitignore

我想忽略.oh-my-zsh裏面的所有內容,除了custom /目錄。但是,custom /具有example.zsh文件和一個名爲example /的目錄,其中包含example.plugin.zsh文件,我也想忽略它們。

使其更清晰,結構可以被認爲是這樣的:

.oh-my-zsh/ 
    custom/ 
    my-folder-to-be-kept/ 
     .. 
    example/ 
     example.plugin.zsh 
    example.zsh 
    lib/ 
    log/ 
    ... 

我在我的主目錄中的.gitignore:

/.oh-my-zsh/* 
!/.oh-my-zsh/custom/ 
/.oh-my-zsh/custom/example.zsh 
/.oh-my-zsh/custom/example/example.plugin.zsh 

然而,裏面有一個的.gitignore文件。 oh-my-zsh,其中包含以下內容:

locals.zsh 
log/.zsh_history 
projects.zsh 
custom/* 
!custom/example 
!custom/example.zsh 
*.swp 
!custom/example.zshcache 
cache/ 

當我添加未跟蹤文件時,example.p lugin.zsh被忽略,但example.zsh不是。因此,我想我必須忽略.oh-my-zsh中的.gitignore,這樣我的.gitignore才能工作,因爲!custom/example.zsh是衝突的。

回答

1

從混帳

Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file.

的幫助當作你的 「子的.gitignore」 的文件將覆蓋位於根的.gitignore你的問題實際上應該是

Can I make a .gitignore file to have no effect?

而且答案是不。有一些方法可以忽略.gitignore文件,但這隻會避免提交文件,而它仍然會影響必須忽略的內容。

作爲一個經驗法則,在一個項目中有多個.gitignore是一個壞習慣。在你的情況下,我會嘗試修改生成的.gitignore的內容以避免該問題或直接生成它的方式。你的情況聽起來很奇怪,我認爲你做錯了什麼或者做得更好。你應該再考慮一次並重新構思你的概念。任何其他解決方案將只是一個工作

+0

問題是我不能。我必須遵循這個,因爲這是哦我的zsh所需的結構。這個.gitignore是在安裝時生成的,不是由我創建的,也不是通過某種配置進行定製的。 –

+0

我認爲沒有辦法做到這一點。你應該找到一個解決它的方法來改變其他.gitignore的創建方式 – iberbeu