2014-02-28 46 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