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
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.
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.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.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
.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: