Search code examples
gitbashforeachgit-submodules

Bash: Git submodule foreach?


I have sup aliased to submodule foreach 'git co master; git up' (co & up are aliases for checkout & pull --rebase, respectively.).

How do add a condition so that if the submodule name is Libraries/JSONKit, it checks out the branch named experimental, instead of master?


Solution

  • Add the following to .git/config:

    [alias]
        sup = "submodule foreach 'if [ $name == \"Libraries/JSONKit\" ]; then git co experimental; else git co master; fi; git up'"