0

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?

Community
  • 1
  • 1
Eben
  • 157
  • 4
  • `git fetch -all` should work, and works locally for me (I have 15 configured remotes). Are you sure `internal` and `external` contain what you think they do? What command are you using to "clone them" that fails? – Christopher Aug 07 '12 at 17:15
  • Thanks Christopher. It is always reassuring to know if something should work with the setup in question or not. Then you can at least be sure that it is just a user issue. – Eben Aug 08 '12 at 05:04

2 Answers2

1
git fetch internal --all
git fetch external --all
KingCrunch
  • 128,817
  • 21
  • 151
  • 173
-1

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

[remote "internal"]
    url = path_to_my_remote_repo
    fetch = +refs/heads/master:refs/remotes/internal/master

and changing it to this

[remote "internal"]
    url = path_to_my_remote_repo
    fetch = +refs/heads/*:refs/remotes/internal/*

solved the problem for me.

Community
  • 1
  • 1
Eben
  • 157
  • 4