我最近重新组织了我的点文件,使其位于 ~/Dropbox/dotfiles
的 Git 存储库中,并且使用 Pathogen 将所有 Vim 插件捆绑在 ~/Dropbox/dotfiles/home/.vim/ 中捆绑
。这些插件作为 Git 子模块添加。
现在的问题是,当我运行 Vim 时,它会自动生成所有插件的文档并将它们放入每个子模块目录中。这会将未跟踪的内容添加到子模块中,这是我想避免的。
ruby-1.8.7-p330@gs ~/Dropbox/dotfiles ‹master*› $ git st
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
#
# modified: home/.vim/bundle/fuzzyfinder (untracked content)
# modified: home/.vim/bundle/l9 (untracked content)
# modified: home/.vim/bundle/matchit (untracked content)
# modified: home/.vim/bundle/ruby (untracked content)
# ...
no changes added to commit (use "git add" and/or "git commit -a")
我尝试将 .gitignore
文件添加到我的 Git 存储库的根目录中,以忽略子模块内的所有 doc
文件夹,但这似乎不起作用:
home/.vim/bundle/**/doc
我的问题:是有没有办法忽略 Git 子模块内的文件和文件夹,或者配置 Vim 在 Git 存储库外部的文件夹中创建文档?
编辑:正如兰迪·莫里斯指出的,这可能是 生成标签的重复根据病原体的不同位置
I recently reorganized my dotfiles to live inside a Git repository at ~/Dropbox/dotfiles
and I'm using pathogen to bundle all Vim addons inside ~/Dropbox/dotfiles/home/.vim/bundle
. These addons were added as Git submodules.
Now the problem is, when I run Vim, it automatically generates the documentation for all addons and puts them inside each submodule directory. This adds untracked content to the submodules, which I'd like to avoid.
ruby-1.8.7-p330@gs ~/Dropbox/dotfiles ‹master*› $ git st
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
#
# modified: home/.vim/bundle/fuzzyfinder (untracked content)
# modified: home/.vim/bundle/l9 (untracked content)
# modified: home/.vim/bundle/matchit (untracked content)
# modified: home/.vim/bundle/ruby (untracked content)
# ...
no changes added to commit (use "git add" and/or "git commit -a")
I tried to add a .gitignore
file to the root of my Git repository to ignore all doc
folders inside submodules, but this doesn't seem to work:
home/.vim/bundle/**/doc
My question: is there a way to ignore files and folders inside Git submodules or maybe configure Vim to create the documentation in a folder outside the Git repository?
EDIT: as Randy Morris pointed out, this might be a duplicate of Generating tags to different location by pathogen
发布评论
评论(4)
您应该在每个子模块中添加
.gitignore
。由于所述子模块就像嵌套的 Git 存储库,因此它们负责自己的忽略规则,并且它们的状态不会受到父存储库的
.gitignore
的影响(如 此处解释)。对于特定于 vim 的设置,如 Randy Morris 在评论中提到的,请参阅 SO 问题“根据病原体生成不同位置的标签”。
注意:正如 Nick 在此评论中提到的,以及“根据病原体生成不同位置的标签",如下配置:
将起作用并生成该子模块被
git status
忽略。但是“
ignore = untracked
”表示至少 Git1.7.2。配置通常位于存储库的
.git/
文件夹中。注意:nurettin 提到在评论中:
Commit aee9c7d 详细说明了
未跟踪
和脏
之间的区别。“
dirty
”:只有超级项目和子模块HEAD
中记录的提交差异才会被视为修改,所有对子模块工作树的更改将被忽略。使用此值时,根本不会扫描子模块的工作树更改,从而提高大型子模块的性能优势。
“
untracked
”:仅忽略子模块工作树中未跟踪的文件、子模块中已更改的HEAD
和/或修改的文件会将其标记为已修改。You should add
.gitignore
within each of your submodules.Since said submodules are like nested Git repo, they take care of their own ignore rules, and their status wouldn't be influenced by the
.gitignore
of the parent repo (as explained here).For a vim-specific setting, as Randy Morris mentions in the comment, see the SO question "Generating tags to different location by pathogen".
Note: as Nick mentions in this comments, and as illustrated by the answer to "Generating tags to different location by pathogen", a config like:
will work and make that submodule ignored by
git status
.But "
ignore = untracked
" means at least Git1.7.2.The config is usually found in the
.git/
folder of your repo.Note: nurettin mentions in the comments:
Commit aee9c7d details the difference between
untracked
anddirty
."
dirty
": Only differences of the commit recorded in the superproject and the submodulesHEAD
will be considered modifications, all changes to the work tree of the submodule will be ignored.When using this value, the submodule will not be scanned for work tree changes at all, leading to a performance benefit on large submodules.
"
untracked
": Only untracked files in the submodules work tree are ignored, a changedHEAD
and/or modified files in the submodule will mark it as modified.VonC 的
ignore = untracked
建议可行,但您必须对每个此类子模块进行更改。如果你想一劳永逸地解决问题,你可以在每个 git repo 上配置一个全局 gitignore 模式,通过 git config --global core.excludesfile ~/.gitignore_global ,然后只需添加
doc/tags
到 $HOME/.gitignore_global。请参阅https://help.github.com/articles/ignoring-files。
VonC's recommendation of
ignore = untracked
works, but you have to make the change for every such submodule.If you want to solve the problem once and for all, you can configure a global gitignore pattern on every git repo, by
git config --global core.excludesfile ~/.gitignore_global
, then just adddoc/tags
to $HOME/.gitignore_global.See https://help.github.com/articles/ignoring-files.
本的回答是一个好的开始。但对于这种特定的忽略规则,我不喜欢全局设置。
首选每个子模块的本地配置,以及子模块根存储库中的集中忽略文件:
Ben's answer is a good start. But for such specific ignore rule, I don't like the global setting.
Prefer local config for each submodule, and a centralized ignore file in submodule root repository:
我认为这里的基本问题是您试图忽略“跟踪”更改。
.gitignore
仅忽略对存储库的“未跟踪”更改。要验证您是否可以修改存储库(已跟踪)中的某些文件,并将其添加到您的.gitignore
文件中。在执行 git status 时,您将看到该文件仍列为“已修改”。您的子模块存储库也被视为由主存储库跟踪,因此简单地向父存储库添加 gitignore 是行不通的。正如其他人所建议的,要么添加 .gitignore 规则单个存储库,或者如果您使用的是最新的 git 版本,则可以使用 git status --ignore-submodules 。I think the basic problem here is that you are trying to ignore a 'tracked' change.
.gitignore
ignores only 'untracked' changes to the repo. To verify you can modify some file in your repo (which tracked) and also add it to your.gitignore
file. On doinggit status
you will see that the file is still listed as 'modified'. Your submodule repo's are also considered tracked by your main repo, hence simply adding a gitignore to the parent repo won't work. As othere suggested, either add.gitignore
rules individual repo's or if you're using a recent git version, you can use thegit status --ignore-submodules
.