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
No, you don't need to add your submodule to your . gitignore : what the parent will see from your submodule is a gitlink (a special entry, mode 160000 ). That means: any change directly made in a submodule needs to be followed by a commit in the parent directory.
This goes for C#, Ruby, and React projects, too. Your first commit should generally include your . gitignore file. Once again, make sure to avoid pushing any files that you want to ignore when you make that first commit — because GitHub won't know they should be ignored yet.
gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.
This is because of some major drawbacks around git submodules, such as being locked to a specific version of the outer repo, the lacking of effective merge management, and the general notion that the Git repository itself doesn't really know it's now a multi-module repository.
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:
[submodule "path/to/submodule"] path = path/to/submodule url = http://github.com/username/repo.git ignore = untracked # <====
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:
ignore = dirty
did it for me
Commit aee9c7d details the difference between untracked
and dirty
.
"dirty
": Only differences of the commit recorded in the superproject and the submodules HEAD
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 changed HEAD
and/or modified files in the submodule will mark it as modified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With