I have a project with a handful of submodules. Many of them are cloned from a GitHub fork to which I've added a branch for my custom mods. A typical setup is like thus:
In local folder: MyProject1/Frameworks/SomeAmazingRepo/
$ git branch -vva
*my-fork 123456 [my-fork/my-fork] Latest commit msg from fork
master abcdef [origin/master] Latest commit msg from original repo
remotes/my-fork/my-fork 123456 [my-fork/my-fork] Latest commit msg from fork
remotes/my-fork/master abcdef [origin/master] Latest commit msg from original repo
remotes/origin/HEAD -> origin/master
remotes/origin/master abcdef [origin/master] Latest commit msg from original repo
$ git remote -v
my-fork git@github.com:MyUser/SomeAmazingRepo.git (fetch)
my-fork git@github.com:MyUser/SomeAmazingRepo.git (push)
origin git://github.com/OriginalOwner/SomeAmazingRepo.git (fetch)
origin git://github.com/OriginalOwner/SomeAmazingRepo.git (push)
I git clone --recursive
my project to begin a new spin-off project and when it begins to recurse, it spits out an error claiming it can't find the stored commits for these repos. Upon inspection it seems that the remotes haven't been added and the branch is left (empty) in master ...
In local folder: MyProject2/Frameworks/SomeAmazingRepo/
$ git branch -vva
*master abcdef [origin/master] Latest commit msg from original repo
remotes/origin/HEAD -> origin/master
remotes/origin/master abcdef [origin/master] Latest commit msg from original repo
$ git remote -v
origin git://github.com/OriginalOwner/SomeAmazingRepo.git (fetch)
origin git://github.com/OriginalOwner/SomeAmazingRepo.git (push)
The only remedy is to go and add the remotes manually to all the repos (very tedious).
There exists a similar issue in the cases where there are two tracking branches as above but only one remote (origin => my github fork). In these case, it finds the commit and checks it out but fails to recreate the tracking branch, leaving a "dangling" commit...very scary as it doesn't warn you!
How do I clone my project so that it reliably recreates the submodules' remotes and branches?