The behaviour of git commit -a seems to be to include changes to submodules, if they have new commits inside them. This isn't what I normally want, and I sometimes find myself accidentally pushing a commit with submodule changes that I didn't intend to include.

Is there a way to set git commit -a to ignore submodules? I had a look in git help config and didn't see anything.

A (less good) alternative might be to get git status to make it clearer at a glance whether git commit -a would include a submodule. Currently it shows either

modified:   submodule (modified content)


modified:   submodule (new commits)

and those are annoyingly similar. It looks like the submodule.<name>.ignore config option can do something like what I want. But ideally I'd still like to see changes to submodules, just not in the same place as all my other changes unless git commit -a will add them.


You can set the submodule.ignore in git config or in the .gitmodules file.

NOTE: GIT is kind of stupid with this. If you set ignore = all, to get sane behavior with git commit -a, it will ALSO ignore the submodule in git show/diff when you EXPLICITLY add them. The only way to work-around the latter is using the command line option --ignore-submodule=none.

NOTE2: The diff.ignoreSubmodules config is supposed to be able to set the default command line option --ignore-submodule, but has been broken for years, and does nothing as .gitmodules wins the contest, so only explicit command line options will get you sane behavior.

  • Where exactly do you use ` --ignore-submodule=none` ? – Peter Oct 16 '19 at 16:43

If you don't have a ton of submodules, what I found the most convenient is to first commit all, then run

git reset HEAD^1 submodule_path

You can always get a reminder of this command syntax if you run git commit --amend without any change. It will show up near the top of the commented instructions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.