I have a setup with 3 remote repositories, origin, internal, external.
When I create a new local installation of these, I clone origin and add internal and external as remotes.
New remote branches on origin show up when I do
git fetch –all
but on internal and external they don’t seem to be fetched from the server (although I see that the servers are contacted and queried).
I have tried also git remote update internal without any luck.
With git ls-remote internal I can see any newly created remote branches but I can’t clone them (probably because the information about the branches haven’t been fetched to my local repository).
Searching the internet I found this blog post http://www.jukie.net/bart/blog/fetch-all-git-branches which describes the same problem and solves it with a custom script.
When you clone a new git repository, using a recent git release, by default git will create a .git/remotes/origin with all remote branches. This file lists all remote branches that are to be updated on a fetch.
Over time the remote may get more branches, and it may be necessary to update the remote branch list. The way to find out what is available at a remote is to call git-ls-remote origin, then pick out the branches of interest, and add them to the .git/remotes/origin file.
Why doesn’t git fetch –all update the .git/remotes/[remote_name] file with new branches?
Is there really no way to update this with normal git commands?
I found this other post [1]: In git, how do I check out a remote repository's remote branches? which pointed me to look in the git config for my setup. For some reason I had managed to get the remote to track only the master branch instead of the default glob refspec for the remote (under the refs/remotes/remote_name/ namespace).
So my config looked like this
and changing it to this
solved the problem for me.