Git: can I suppress listing of 'modified content'/dirty submodule entries in status, diff, etc?

后端 未结 9 1641
谎友^
谎友^ 2020-11-28 02:32

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


        
相关标签:
9条回答
  • 2020-11-28 02:58

    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 = git@github.com: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 = git@github.com:user/media.git
       ignore = all
    
    0 讨论(0)
  • 2020-11-28 02:58

    You need to add

    ignore = dirty

    to .gitmodules

    0 讨论(0)
  • 2020-11-28 02:58

    I've answered this question here in greater detail.

    Just run

    git config --global diff.ignoreSubmodules dirty
    

    to add a local config option to ignore those changes.

    0 讨论(0)
提交回复
热议问题