{"thread":{"id":"6882","subject":"Where/how to create tracking branches?","startedAt":"2007-02-19T16:45:41Z","lastAt":"2007-02-19T21:09:12Z","messageCount":4,"participants":["Bill Lear","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"35014","messageId":"17881.54325.475907.468492@lisa.zopyra.com","threadId":"6882","inReplyTo":null,"subject":"Where/how to create tracking branches?","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-02-19T16:45:41Z","receivedAt":"2007-02-19T16:45:41Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"What is the recommended way to create tracking branches in my private\nrepo if I first create the corresponding topic branch in my private\nrepo and want to publish it via a public repo?\n\nScenario:\n\n[my private repo]\n% git checkout -b topic\n[work, work, work, commit]\n% git push /public/repo/project topic:topic\n\n[somebody else:]\n% git clone /public/repo/project\n% git checkout -b topic origin/topic\n[work, work, work, commit]\n% git push /public/repo/project topic:topic\n\n[my private repo]\n% git checkout topic\n% git pull /public/repo/project topic\nremote: Generating pack...\nremote: Done counting 5 objects.\nResult has 3 objects.\nremote: Deltifying 3 objects.\nremote: /3) done/3) done\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking 3 objects\n 100% (3/3) done\nUpdating 4751fcc..2d92737\nFast forward\n A |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n% git branch\n  master\n* topic\n% git branch -r\n  origin/HEAD\n  origin/master\n\nNow, I'm on my private repo, but I really want a tracking branch for\ndoing pulls from my public repo, or peers, for this topic branch.\n\nDo I have to create the topic branch in my public repo first?  This\nseems crazy, as our company repo is just another \"global\" public repo\nand each developer would need to create branches there instead of on\ntheir own machine.\n\nI tried this:\n\n% git pull /public/repo/project topic:origin/topic\n\nBut it created a topic branch named \"origin/topic\" instead of a tracking\nbranch.\n\n\nBill\n"},{"id":"35019","messageId":"7vy7mu6ihj.fsf@assigned-by-dhcp.cox.net","threadId":"6882","inReplyTo":"17881.54325.475907.468492@lisa.zopyra.com","subject":"Re: Where/how to create tracking branches?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-19T19:43:36Z","receivedAt":"2007-02-19T19:43:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bill Lear <rael@zopyra.com> writes:\n\n> What is the recommended way to create tracking branches in my private\n> repo if I first create the corresponding topic branch in my private\n> repo and want to publish it via a public repo?\n>\n> Scenario:\n>\n> [my private repo]\n> % git checkout -b topic\n> [work, work, work, commit]\n> % git push /public/repo/project topic:topic\n\nSo at this point the public shared repository has refs/heads/topic\nbranch you and colleagues can work on together.  So I am puzzled\nabout this part...\n\n> Do I have to create the topic branch in my public repo first?  This\n> seems crazy,...\n\nbecause you did do so and I do not think it is crazy.\n\nMaybe you meant \"do I create tracking branch for 'topic' in public?\",\nin which case the answer is no.\n\n> I tried this:\n>\n> % git pull /public/repo/project topic:origin/topic\n>\n> But it created a topic branch named \"origin/topic\" instead of a tracking\n> branch.\n\nAssuming your clone was initially made from /public/repo/project,\ndoesn't \"git fetch\" without _any_ parameter work?\n\n\t$ git fetch\n"},{"id":"35027","messageId":"17882.1230.704770.12880@lisa.zopyra.com","threadId":"6882","inReplyTo":"7vy7mu6ihj.fsf@assigned-by-dhcp.cox.net","subject":"Re: Where/how to create tracking branches?","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-02-19T20:13:02Z","receivedAt":"2007-02-19T20:13:02Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Monday, February 19, 2007 at 11:43:36 (-0800) Junio C Hamano writes:\n>...\n>Assuming your clone was initially made from /public/repo/project,\n>doesn't \"git fetch\" without _any_ parameter work?\n>\n>\t$ git fetch\n\nShort answer: yes, it does.  I had assumed I needed to create the\ntracking branch somehow since I created the topic branch in the first\nplace in my private repo.  More detailed confirmation follows, but\nthank you for pointing out that git is in fact smarter than I gave\nit credit.\n\n# set up a public repo with \"master\" branch and something in it...\nmkdir public_repo && cd public_repo && git --bare init\ncd ..\nmkdir a_repo && cd a_repo && git init\necho A > A && git add A && git commit -a -m A\ngit push ../public_repo master:master\n\n# clone public repo to get my private repo, create topic branch\ncd ..\ngit clone public_repo private_repo\ncd private_repo\ngit checkout -b topic\necho change >> A && git commit -a -m change\n\n# publish my branch 'topic' to my public repo\ngit push ../public_repo topic:topic\n\n# A peer grabs the topic branch, makes changes and pushes back to public\ncd ..\ngit clone public_repo peer_repo\ncd peer_repo\ngit checkout -b topic origin/topic\necho more >> A && git commit -a -m more\ngit push ../public_repo topic:topic\n\n# Go to my private repo, pull latest changes (show output this time...)\ncd ../private_repo\ngit checkout master\ngit pull\nremote: Generating pack...\nremote: Done counting 5 objects.\nResult has 3 objects.\nremote: Deltifying 3 objects.\nremote: /3) done/3) done\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking 3 objects\n 100% (3/3) done\n* refs/remotes/origin/topic: storing branch 'topic' of /home/blear/test/public_repo\n  commit: 4a8e157\nAlready up-to-date.\n\n# Now, switch to topic branch\ngit checkout topic\ncat A\nA\nchange\n\n# Ok, now I get it:\ngit diff origin/topic\n[changes listed]\ngit merge origin/topic\ncat A\nA\nchange\nmore\n\n\nBill\n"},{"id":"35033","messageId":"7v1wkl7t3b.fsf@assigned-by-dhcp.cox.net","threadId":"6882","inReplyTo":"17882.1230.704770.12880@lisa.zopyra.com","subject":"Re: Where/how to create tracking branches?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-19T21:09:12Z","receivedAt":"2007-02-19T21:09:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bill Lear <rael@zopyra.com> writes:\n\n> On Monday, February 19, 2007 at 11:43:36 (-0800) Junio C Hamano writes:\n>>...\n>>Assuming your clone was initially made from /public/repo/project,\n>>doesn't \"git fetch\" without _any_ parameter work?\n>>\n>>\t$ git fetch\n>\n> Short answer: yes, it does.  I had assumed I needed to create the\n> tracking branch somehow since I created the topic branch in the first\n> place in my private repo.  More detailed confirmation follows, but\n> thank you for pointing out that git is in fact smarter than I gave\n> it credit.\n\nTracking new branches on the remote side after you create a\nclone is one of the few things 1.5.0 does much better than 1.4.4\nseries, and it was done in response to comments from real world\nusers like yourself, so rather than giving git too much credit,\nI think you should take it yourself ;-).\n"}]}