Git: track branch in submodule but commit in other submodule (possibly nested)

Update 2020: The OP BartBog reports in the comments: The current (2016) answer does not work that well (anymore?) with subsubmodules since $top/.gitmodules does not contain the branch info of the subsub (and subsubsub modules) New solution: export top=$(pwd) git submodule foreach ‘b=$(git config -f ${top}/.gitmodules submodule.${path}.branch); \ case “${b}” in \ “”) git checkout … Read more

Git submodule on remote bare

I figured out another solution which looks rather clean to me. Just give git all the info it needs to perform the submodule stuff: $ cd /path/to/your/git_work_tree $ git –git-dir=/path/to/your/bare_repo.git –work-tree=. submodule init $ git –git-dir=/path/to/your/bare_repo.git –work-tree=. submodule update