{"thread":{"id":"43384","subject":"Re: Getting new branches from remote repo.","startedAt":"2006-11-13T04:33:52Z","lastAt":"2006-11-13T18:40:51Z","messageCount":9,"participants":["Junio C Hamano","Matthias Hopf","Jakub Narebski","Alexander Litvinov","Karl Hasselström","Shawn Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"297209","messageId":"6e1787fe0611122033p49671e13xf5b7f95beeba8b06@mail.gmail.com","threadId":"43384","inReplyTo":null,"subject":"Getting new branches from remote repo.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2006-11-13T04:33:52Z","receivedAt":"2006-11-13T04:33:52Z","isPatch":false,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"Hello list,\n\nI have a trouble I don't know how to solve. When I am cloning remote\nrepo I automatically get all it's branches stored at my repo (they are\nlisted at .git/remotes/origin). When someone adds new branch(es) to\nremote repo git pull (git fetch) does not automatically add them to my\nrepo. I have a tool to list all remote branches (git ls-remote --heads\norigin) but I can't find how to add interesting (or all) branches to\nby repo.\n\nBy the way, how can I clone remote repo created by cloning another\nrepo using git clone --use-separate-remotes ? Even git ls-remote\n--heads origin does not show all branches taken from that another\nrepo.\n\n"},{"id":"297061","messageId":"7v8xigar36.fsf@assigned-by-dhcp.cox.net","threadId":"43384","inReplyTo":"6e1787fe0611122033p49671e13xf5b7f95beeba8b06@mail.gmail.com","subject":"Re: Getting new branches from remote repo.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-13T04:49:33Z","receivedAt":"2006-11-13T04:49:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alexander Litvinov\" <litvinov2004@gmail.com> writes:\n\n> I have a trouble I don't know how to solve. When I am cloning remote\n> repo I automatically get all it's branches stored at my repo (they are\n> listed at .git/remotes/origin). When someone adds new branch(es) to\n> remote repo git pull (git fetch) does not automatically add them to my\n> repo. I have a tool to list all remote branches (git ls-remote --heads\n> origin) but I can't find how to add interesting (or all) branches to\n> by repo.\n\nAfter finding out $that_new_branch's name, add either\n\n\tPull: refs/heads/$that_new_branch:refs/heads/$that_new_branch\n\nor if you are in \"separate remote\" school, then perhaps\n\n\tPull: refs/heads/$that_new_branch:refs/remotes/origin/$that_new_branch\n\nto .git/remotes/origin and running git fetch would give you what\nyou want, I think.\n\n> By the way, how can I clone remote repo created by cloning another\n> repo using git clone --use-separate-remotes ? Even git ls-remote\n> --heads origin does not show all branches taken from that another\n> repo.\n\nWell, the point of \"separate remote\" is not to pollute local\nheads/ namespace with refs that merely track remote repository,\nso if you say \"ls-remote --heads\" you would not see them.  They\nare not \"heads\" in that repository.\n\nYou would still see them if you say \"ls-remote\" without --heads.\n"},{"id":"296096","messageId":"6e1787fe0611122129l211f7bcaued9f4981225a241b@mail.gmail.com","threadId":"43384","inReplyTo":"7v8xigar36.fsf@assigned-by-dhcp.cox.net","subject":"Re: Getting new branches from remote repo.","fromName":"Alexander Litvinov","fromEmail":"litvinov2004@gmail.com","sentAt":"2006-11-13T05:29:25Z","receivedAt":"2006-11-13T05:29:25Z","isPatch":false,"sender":{"key":"litvinov2004@gmail.com","avatar":null},"body":"> After finding out $that_new_branch's name, add either\n>\n>         Pull: refs/heads/$that_new_branch:refs/heads/$that_new_branch\n\n> You would still see them if you say \"ls-remote\" without --heads.\n\nThanks for help, these commands solve my trouble:\n1. Get remote branches by 'git ls-remote origin refs/remotes/*'\n2. Fetch needed branch by adding: 'Pull:\nrefs/remotes/origin/BRANCH:refs/heads/BRANCH' into .git/remotes/origin\n\nIs there any way to automaticly edit .git/remotes/origin before\n"},{"id":"297238","messageId":"20061113091736.GA31693@diana.vm.bytemark.co.uk","threadId":"43384","inReplyTo":"7v8xigar36.fsf@assigned-by-dhcp.cox.net","subject":"Re: Getting new branches from remote repo.","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-11-13T09:17:36Z","receivedAt":"2006-11-13T09:17:36Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2006-11-12 20:49:33 -0800, Junio C Hamano wrote:\n\n> \"Alexander Litvinov\" <litvinov2004@gmail.com> writes:\n>\n> > I have a trouble I don't know how to solve. When I am cloning\n> > remote repo I automatically get all it's branches stored at my\n> > repo (they are listed at .git/remotes/origin). When someone adds\n> > new branch(es) to remote repo git pull (git fetch) does not\n> > automatically add them to my repo. I have a tool to list all\n> > remote branches (git ls-remote --heads origin) but I can't find\n> > how to add interesting (or all) branches to by repo.\n>\n> After finding out $that_new_branch's name, add either\n>\n>       Pull: refs/heads/$that_new_branch:refs/heads/$that_new_branch\n>\n> or if you are in \"separate remote\" school, then perhaps\n>\n>       Pull: refs/heads/$that_new_branch:refs/remotes/origin/$that_new_branch\n>\n> to .git/remotes/origin and running git fetch would give you what you\n> want, I think.\n\nThere really should be a flag to make git fetch do this job. And if we\nuse separate remotes, the flag should probably default to \"on\".\n\n-- \nKarl Hasselström, kha@treskal.com\n"},{"id":"294975","messageId":"20061113165709.GA21588@suse.de","threadId":"43384","inReplyTo":"20061113091736.GA31693@diana.vm.bytemark.co.uk","subject":"Re: Getting new branches from remote repo.","fromName":"Matthias Hopf","fromEmail":"mhopf@suse.de","sentAt":"2006-11-13T16:57:09Z","receivedAt":"2006-11-13T16:57:09Z","isPatch":false,"sender":{"key":"mhopf@suse.de","avatar":null},"body":"On Nov 13, 06 10:17:36 +0100, Karl Hasselström wrote:\n> > > I have a trouble I don't know how to solve. When I am cloning\n> > > remote repo I automatically get all it's branches stored at my\n> > > repo (they are listed at .git/remotes/origin). When someone adds\n> > > new branch(es) to remote repo git pull (git fetch) does not\n> > > automatically add them to my repo. I have a tool to list all\n> > > remote branches (git ls-remote --heads origin) but I can't find\n> > > how to add interesting (or all) branches to by repo.\n> >\n> > After finding out $that_new_branch's name, add either\n> >       Pull: refs/heads/$that_new_branch:refs/heads/$that_new_branch\n> > or if you are in \"separate remote\" school, then perhaps\n> >       Pull: refs/heads/$that_new_branch:refs/remotes/origin/$that_new_branch\n> > to .git/remotes/origin and running git fetch would give you what you\n> > want, I think.\n> \n> There really should be a flag to make git fetch do this job. And if we\n> use separate remotes, the flag should probably default to \"on\".\n\nThis was an issue I stumbled upon recently, which was discussed on\nX.org's mailing list. I wanted to sumarize that here, but didn't have\ntime for that so far.\n\nRight now I use the following UGLY script to do exactly that:\n\ngit-ls-remote -h origin | cut -f 2 | perl -e 'while (<>) { chomp;\n$h{$_}=$_; } open F, \".git/remotes/origin\" or die; while (<F>) { print;\nif (/^Pull:\\s+([^: ]*):/) { delete $h{$1}; } } foreach $f (keys %h) {\nprint \"Pull:   ${f}:$f\\n\"; }' > newfile\nmv newfile .git/remotes/origin\n\n(modulo some safety tests), but that doesn't work right for origin files\nwith multiple URL: statements (I very much assume they are possible).\n\nI second that there should be a flag to make git fetch do that\nautomatically, and at least all \"git for CVS users\" tutorials should\ninclude this flag, as this is exactly how CVS works (otherwise you\ncannot check out another branch that happens to be added upstream).\n\nMatthias\n\n-- \nMatthias Hopf <mhopf@suse.de>       __        __   __\nMaxfeldstr. 5 / 90409 Nuernberg    (_   | |  (_   |__         mat@mshopf.de\nPhone +49-911-74053-715            __)  |_|  __)  |__  labs   www.mshop"},{"id":"297490","messageId":"20061113174457.GA16979@spearce.org","threadId":"43384","inReplyTo":"20061113091736.GA31693@diana.vm.bytemark.co.uk","subject":"Re: Getting new branches from remote repo.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-13T17:44:57Z","receivedAt":"2006-11-13T17:44:57Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Karl Hasselstr?m <kha@treskal.com> wrote:\n> On 2006-11-12 20:49:33 -0800, Junio C Hamano wrote:\n> > After finding out $that_new_branch's name, add either\n> >\n> >       Pull: refs/heads/$that_new_branch:refs/heads/$that_new_branch\n> >\n> > or if you are in \"separate remote\" school, then perhaps\n> >\n> >       Pull: refs/heads/$that_new_branch:refs/remotes/origin/$that_new_branch\n> >\n> > to .git/remotes/origin and running git fetch would give you what you\n> > want, I think.\n> \n> There really should be a flag to make git fetch do this job. And if we\n> use separate remotes, the flag should probably default to \"on\".\n\nAnd also to automatically stop fetching any branch which is no longer\nlisted on the remote system, rather than reporting a \"Fetch failure\".\n\nI probably would keep the local ref (they are cheap) just in case\nthe user was counting on that branch and then the remote system\npulled the rug out from under them.  :-)\n\n-- \n"},{"id":"297807","messageId":"20061113175354.GA16094@diana.vm.bytemark.co.uk","threadId":"43384","inReplyTo":"20061113174457.GA16979@spearce.org","subject":"Re: Getting new branches from remote repo.","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-11-13T17:53:54Z","receivedAt":"2006-11-13T17:53:54Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2006-11-13 12:44:57 -0500, Shawn Pearce wrote:\n\n> Karl Hasselström <kha@treskal.com> wrote:\n>\n> > There really should be a flag to make git fetch do this job. And\n> > if we use separate remotes, the flag should probably default to\n> > \"on\".\n>\n> And also to automatically stop fetching any branch which is no\n> longer listed on the remote system, rather than reporting a \"Fetch\n> failure\".\n\nYes.\n\n> I probably would keep the local ref (they are cheap) just in case\n> the user was counting on that branch and then the remote system\n> pulled the rug out from under them. :-)\n\nSounds like good default behavior. But I smell the potential for\nanother command flag here. :-)\n\n-- \nKarl Hasselström, kha@treskal.com\n"},{"id":"294576","messageId":"7vr6w78b4x.fsf@assigned-by-dhcp.cox.net","threadId":"43384","inReplyTo":"20061113091736.GA31693@diana.vm.bytemark.co.uk","subject":"Re: Getting new branches from remote repo.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-13T18:17:02Z","receivedAt":"2006-11-13T18:17:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karl Hasselström <kha@treskal.com> writes:\n\n>> After finding out $that_new_branch's name, add either\n>>\n>>       Pull: refs/heads/$that_new_branch:refs/heads/$that_new_branch\n>>\n>> or if you are in \"separate remote\" school, then perhaps\n>>\n>>       Pull: refs/heads/$that_new_branch:refs/remotes/origin/$that_new_branch\n>>\n>> to .git/remotes/origin and running git fetch would give you what you\n>> want, I think.\n>\n> There really should be a flag to make git fetch do this job. And if we\n> use separate remotes, the flag should probably default to \"on\".\n\nWhile I do not necessarily agree that \"git fetch\" is the place\nto do so, I think it is sensible to have a way to easily manage\nremotes/$origin file.\n\nThings to consider are:\n\n - We need to notice new branches at the other end.\n\n - We need to remember old branches that the user is not\n   interested in, so that we do not even ask to add it only\n   because it does not have a local tracking branch.\n\n - We need to notice branches that disappeared at the other\n   end.  We may want to offer the choice between droping the\n   local tracking branch and keeping it in the 'the last\n   fetched' state.\n\nSo from the UI point of view, considering that \"git fetch\" might\nbe called as a part of \"git pull\", a sensible thing to do would\nbe:\n\n - Add \"Pull-ignored:\" lines to list remote branches that the\n   user is not interested in to .git/remotes/$origin file, and\n   teach existing tools to ignore them.\n\n - Make \"git fetch\" to always run \"ls-remote\" (we would need to\n   do this anyway to enable commit walkers to fetch from a\n   repository that has packed and then pruned its refs) upfront,\n   and do the \"noticing\" part and issue an info message when\n   there are new branches (we should only do this when a\n   shorthand from .git/remotes/ is used).\n\n - Add \"git maint-remote\" command that lets the user compare\n   ls-remote output and Pull: lines from remotes/$origin file,\n   and add/modify/delete the mapping to local tracking branches.\n\nI think the last one is probably the easiest for the users if\ndone with something like dialog or whiptail.\n"},{"id":"295701","messageId":"ejae5a$5qb$1@sea.gmane.org","threadId":"43384","inReplyTo":"7vr6w78b4x.fsf@assigned-by-dhcp.cox.net","subject":"Re: Getting new branches from remote repo.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-13T18:40:51Z","receivedAt":"2006-11-13T18:40:51Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n>  - We need to remember old branches that the user is not\n>    interested in, so that we do not even ask to add it only\n>    because it does not have a local tracking branch.\n\nWouldn't it be easier just to add --all flag to git-fetch,\nwhich would fetch _all_ the branches, and --save to write remotes\nfile... or rather appropriate config entry?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"}]}