git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Getting new branches from remote repo.

From
MHMatthias Hopf <mhopf@suse.de>
Date
Nov 13, 2006, 16:57 UTC
Message-ID
<20061113165709.GA21588@suse.de>
In-Reply-To
<20061113091736.GA31693@diana.vm.bytemark.co.uk>
On Nov 13, 06 10:17:36 +0100, Karl Hasselström wrote:
Show 17 quoted lines
> > > I have a trouble I don't know how to solve. When I am cloning
> > > remote repo I automatically get all it's branches stored at my
> > > repo (they are listed at .git/remotes/origin). When someone adds
> > > new branch(es) to remote repo git pull (git fetch) does not
> > > automatically add them to my repo. I have a tool to list all
> > > remote branches (git ls-remote --heads origin) but I can't find
> > > how to add interesting (or all) branches to by repo.
> >
> > After finding out $that_new_branch's name, add either
> >       Pull: refs/heads/$that_new_branch:refs/heads/$that_new_branch
> > or if you are in "separate remote" school, then perhaps
> >       Pull: refs/heads/$that_new_branch:refs/remotes/origin/$that_new_branch
> > to .git/remotes/origin and running git fetch would give you what you
> > want, I think.
> 
> There really should be a flag to make git fetch do this job. And if we
> use separate remotes, the flag should probably default to "on".

This was an issue I stumbled upon recently, which was discussed on X.org's mailing list. I wanted to sumarize that here, but didn't have time for that so far.

Right now I use the following UGLY script to do exactly that:

git-ls-remote -h origin | cut -f 2 | perl -e 'while (<>) { chomp; $h{$_}=$_; } open F, ".git/remotes/origin" or die; while (<F>) { print; if (/^Pull:\s+([^: ]*):/) { delete $h{$1}; } } foreach $f (keys %h) { print "Pull: ${f}:$f\n"; }' > newfile mv newfile .git/remotes/origin

(modulo some safety tests), but that doesn't work right for origin files with multiple URL: statements (I very much assume they are possible).

I second that there should be a flag to make git fetch do that automatically, and at least all "git for CVS users" tutorials should include this flag, as this is exactly how CVS works (otherwise you cannot check out another branch that happens to be added upstream).

Matthias
-- 
Matthias Hopf <mhopf@suse.de>       __        __   __
Maxfeldstr. 5 / 90409 Nuernberg    (_   | |  (_   |__         mat@mshopf.de
Phone +49-911-74053-715            __)  |_|  __)  |__  labs   www.mshop
Previous: Karl HasselströmNext: Shawn Pearce
Message 5 of 9 in “Getting new branches from remote repo.”
  1. Alexander LitvinovNov 13, 2006
  2. Junio C HamanoNov 13, 2006
  3. Alexander LitvinovNov 13, 2006
  4. Karl HasselströmNov 13, 2006
  5. Matthias HopfNov 13, 2006
  6. Shawn PearceNov 13, 2006
  7. Karl HasselströmNov 13, 2006
  8. Junio C HamanoNov 13, 2006
  9. Jakub NarebskiNov 13, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.