Tuesday, June 19, 2012

git submodules and branches

normally git submodules are working in a 'detached mode'. This means that if you want to commit some changes, they could be lost (or at least you need to recover it) if you didn't create a branch for it.

But git submodules can also handle automerging/-rebasing on every git submodule update call.

This could be done by setting the correct commandline switch:
$ git submodule update --merge  # for merging 
$ git submodule update --rebase # for rebasing
or you could set it in your git config by issuing
$ git config submodule.[the submodule name].update merge # for merging
$ git config submodule.[the submodule name].update rebase # for rebasing
or doing it all in once
$ for submodule in $(git submodule | cut -d' ' -f1); do git config submodule.${submodule}.update merge; done; # for merging
$ for submodule in $(git submodule | cut -d' ' -f1); do git config submodule.${submodule}.update rebase; done; # for rebasing



BlueC0re