Dear git community, I'd like to report you a potential bug in git submodule implementation. * Problem statement According to doc a special value of "." can be used as a branch name to track. This means that git should trace the same branch as is currently in use in superproject. This works perfectly fine as long as you don't try to add superproject (SUP1) with such configuration as a submodule to another superproject (SUP2). The nesting structure would look like this: SUP2 - SUP1 - SUB_PROJECT If you try to do this you won't be able to execute any of the following commands: $ git clone --recursive SUP2 $ git clone SUP2 & git submodule update --init --recursive --remote $ git submodule update --init --recursive --remote as every time you will get an error message similar to this one: fatal: Submodule (SUB_PROJECT) branch configured to inherit branch from superproject, but the superproject is not on any branch fatal: Needed a single revision Unable to find current origin/ revision in submodule path 'SUB_PROJECT' * Initial investigation results The error message comes from remote_submodule_branch():1938 in submodule--helper.c and it is generated called from SUP1 dir (due to --recursive flag). Actually this function behaves correctly. If you go to SUP1 dir and check the branch info you will notice that the repo is in detached head state. * Probable root cause The root cause is that the traced branch information is never propagated to the submodules. All the submodules are always initialized in a detached head state and there is no way to change this behavior nor to propagate the traced branch information to submodules. * Workaround script I managed to workaround this bug by dropping the recursive option and after the top level project has been cloned I go through every submodule, set local branch to point to current head and then just do git checkout and I do this recursively in all modules. After this I'm able to successfully execute: $ git submodule update --rebase --recursive --remote The script (to be executed in SUP2 right after clone): #!/bin/bash function prepare_submodules { git submodule update --init local SUBMODULE_LIST=`git submodule--helper status | awk '{print $2}'` while read -r submod; do local PARENT_DIR=`pwd` local BRANCH=`git submodule--helper remote-branch ${submod}` cd ${submod} git branch -f ${BRANCH} HEAD; git checkout ${BRANCH} if [ ! -z "`git submodule status`" ]; then prepare_submodules; fi cd ${PARENT_DIR} done <<< "$SUBMODULE_LIST" } prepare_submodules Best regards, -- Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics