Is there a way to ignore dirty submodules when using git add --patch
?
I've set ignore = dirty
as explained here. This seems to only work with git status
and git diff
. I love git add -p
. Having to skip through 10 dirty submodules every time I want to add a small change frustrates me.
I haven't quite figured out git add -i
yet, but it looks like it handles dirty submodules the same way.
Having add silently ignore submodule updates seems, to quote Clint, tooooo dangerous.
I don't know how to do it with add --patch, but I can get pretty close with add --edit and a vim keymapping:
while will map
\\x
to eliminate all submodule update hunks. The\!
s in that are vim-specific bang escapes, strip those backslashes to use the sed elsewhere.With Git 2.16.x/2.17, you won't even need a
--ignore-submodules
option,since "
git add -p
" was taught to ignore local changes to submodules as they do not interfere with the partial addition of regular changes anyway.See commit 12434ef (13 Jan 2018) by Nguyễn Thái Ngọc Duy (
pclouds
).(Merged by Junio C Hamano --
gitster
-- in commit e7e8077, 23 Jan 2018)