Git: can I suppress listing of 'modified content'/dirty submodule entries in status, diff, etc?
Somewhen (around the 1.6.x releases, I think) git became aware of changes inside submodules. That only serves to annoy me:
$ git status vendor | grep modified: # modified: vendor/rails (modified content)
$ git diff vendor/ diff --git a/vendor/rails b/vendor/rails --- a/vendor/rails +++ b/vendor/rails @@ -1 +1 @@ -Subproject commit 046c900df27994d454b7f906caa0e4226bb42b6f +Subproject commit 046c900df27994d454b7f906caa0e4226bb42b6f-dirty
Please make it stop?
Edit:
Ok, so I have an answer. Now I have another question:
Can I put this in ~/.gitconfig
? From my initial it appears that I cannot, and I didn't see anything promising by skimming the patch. (I guess I can still make an alias.)
Solution 1:
There is even a possibility to set the ignore mode for every added submodule within the .gitmodules file.
Just today I encountered this problem and immediately wrote an article in my blog about it after finding a solution: How to ignore changes in git submodules
The gist of it:
Once you added a submodule there will be a file named
.gitmodules
in the root of your repository
Just add one line to that .gitmodules
file:
[submodule "bundle/fugitive"]
path = bundle/fugitive
url = git://github.com/tpope/vim-fugitive.git
ignore = dirty
Solution 2:
There are two kinds of change notices you can suppress.
The first is untracked content
which happens when you make changes to your submodule but have not yet committed those. The parent repository notices these and git status
reports it accordingly:
modified: modules/media (untracked content)
You can suppress these with :
[submodule "modules/media"]
path = modules/media
url = [email protected]:user/media.git
ignore = dirty
However, once you commit those changes, the parent repository will once again take notice and report them accordingly:
modified: modules/media (new commits)
If you want to suppress these too, you need to ignore all
changes
[submodule "modules/media"]
path = modules/media
url = [email protected]:user/media.git
ignore = all