{"thread":{"id":"20731","subject":"Confused about push/pull of a branch","startedAt":"2009-08-25T17:40:47Z","lastAt":"2009-08-25T18:32:30Z","messageCount":5,"participants":["Fritz Anderson","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"121739","messageId":"BA2E0DDB-3DE0-4D49-BFA6-72CFEDEBA5AE@uchicago.edu","threadId":"20731","inReplyTo":null,"subject":"Confused about push/pull of a branch","fromName":"Fritz Anderson","fromEmail":"fritza@uchicago.edu","sentAt":"2009-08-25T17:40:47Z","receivedAt":"2009-08-25T17:40:47Z","isPatch":false,"sender":{"key":"fritza@uchicago.edu","avatar":null},"body":"I can't get a second machine to pull in a branch that's in my remote  \nrepository. I'm confused.\n\nThe remote is a bare repository on machine_1.\n\nIn my working copy on machine_1:\n\nmachine_1$ git branch\n   master\n   search-controller\n   use-tiles\n* webservices\n# The following should not be necessary, as gitk already\n# identifies a remotes/origin/webservices, but just to be sporting:\nmachine_1$ git push origin webservices\nEverything up-to-date\n\nBranch webservices was created after the working copy on machine_2 was  \ncloned.\n\nIn my working copy on machine_2:\n\nmachine_2$ git pull\nPassword:\n# Progress messages, no protests.\nmachine_2$ git checkout webservices\nerror: pathspec 'webservices' did not match any file(s) known to git.\nmachine_2$ git branch\n* master\nmachine_2$\n\ngit-config shows the two repository URLs are identical, net of  \nmachine_2 having to specify a user name and host. The machine_2 .git/ \nconfig shows a section for [branch \"master\"], but not for webservices.  \nIs that the problem? What's the approved way of adding [branch  \n\"webservices\"], and what do I put into it?\n\nI've obviously forgotten something. Or never understood something  \n(there's a lot in Git not to understand). How do I get the webservices  \nbranch onto machine_2, so I can check it out?\n\n\t— F\n"},{"id":"121740","messageId":"8E2E19AE-DFA6-4000-AD73-35739F1E6642@uchicago.edu","threadId":"20731","inReplyTo":"BA2E0DDB-3DE0-4D49-BFA6-72CFEDEBA5AE@uchicago.edu","subject":"Re: Confused about push/pull of a branch","fromName":"Fritz Anderson","fromEmail":"fritza@uchicago.edu","sentAt":"2009-08-25T17:58:25Z","receivedAt":"2009-08-25T17:58:25Z","isPatch":false,"sender":{"key":"fritza@uchicago.edu","avatar":null},"body":"On Aug 25, 2009, at 12:40 PM, Fritz Anderson wrote:\n\n> I can't get a second machine to pull in a branch that's in my remote  \n> repository. I'm confused.\n\nAnd just from half-wittedly fooling around, I tried:\n\nmachine_2$ git pull origin webservices\nPassword:\n From fritza@fritzanderson.uchicago.edu:/Users/fritza/scientia/scientia\n  * branch            webservices -> FETCH_HEAD\nUpdating 3c86901..6b09f9f\nFast forward\n  Calendar/Classes/CalendarWebController.m |    2 ++\n# etc.\n  dirserver/lib/ldaputils.rb               |   15 +++++----------\n  6 files changed, 34 insertions(+), 17 deletions(-)\nmachine_2$ sudo /usr/local/bin/git branch\n* master\nmachine_2$\n\nThis seems to mean that master on machine_2 is now congruent to  \nwebservices on machine_1. That's not what I meant. Is there a way to  \nundo this? git-pull origin-master doesn't seem to do anything.\n\n\t— F\n"},{"id":"121741","messageId":"F7D4EAF0-68C9-4A88-86D4-75FD3B71F015@uchicago.edu","threadId":"20731","inReplyTo":"8E2E19AE-DFA6-4000-AD73-35739F1E6642@uchicago.edu","subject":"Re: Confused about push/pull of a branch","fromName":"Fritz Anderson","fromEmail":"fritza@uchicago.edu","sentAt":"2009-08-25T18:00:24Z","receivedAt":"2009-08-25T18:00:24Z","isPatch":false,"sender":{"key":"fritza@uchicago.edu","avatar":null},"body":"On Aug 25, 2009, at 12:58 PM, Fritz Anderson wrote:\n\n> This seems to mean that master on machine_2 is now congruent to  \n> webservices on machine_1. That's not what I meant. Is there a way to  \n> undo this? git-pull origin-master doesn't seem to do anything.\n\nSigh. \"git pull origin master\". Sorry.\n\n\t— F\n"},{"id":"121742","messageId":"20090825182701.GA23731@coredump.intra.peff.net","threadId":"20731","inReplyTo":"BA2E0DDB-3DE0-4D49-BFA6-72CFEDEBA5AE@uchicago.edu","subject":"Re: Confused about push/pull of a branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-25T18:27:01Z","receivedAt":"2009-08-25T18:27:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 25, 2009 at 12:40:47PM -0500, Fritz Anderson wrote:\n\n> Branch webservices was created after the working copy on machine_2\n> was cloned.\n> \n> In my working copy on machine_2:\n> \n> machine_2$ git pull\n> Password:\n> # Progress messages, no protests.\n> machine_2$ git checkout webservices\n> error: pathspec 'webservices' did not match any file(s) known to git.\n> machine_2$ git branch\n> * master\n> machine_2$\n\nTry \"git branch -a\", which will list remote branches. You likely have a\nremote tracking branch \"origin/webservices\". You can check that out to\nexamine it, or if you want to start working on it locally, try \"git\ncheckout -b webservices origin/webservices\".\n\n> git-config shows the two repository URLs are identical, net of\n> machine_2 having to specify a user name and host. The machine_2 .git/\n> config shows a section for [branch \"master\"], but not for\n> webservices. Is that the problem? What's the approved way of adding\n\n> [branch \"webservices\"], and what do I put into it?\n\nThe branch.webservices config is not necessary for a branch; it just\nsays \"by the way, when you do a pull without arguments and we are on\nthis branch, here is where to pull from\". Doing the \"checkout -b\" above\nwill create such a config section on recent versions of git.\n\n> I've obviously forgotten something. Or never understood something\n> (there's a lot in Git not to understand). How do I get the\n> webservices branch onto machine_2, so I can check it out?\n\nThe branching model in git is a little different than other systems.\nJust because the remote has a branch does not mean _you_ have a branch.\nWhen you fetch from them (or pull, which does a fetch behind the\nscenes), you will have a \"remote tracking branch\" which is your local\ncopy of where their remote branches are. You still need to create your\nown local branch if you want to do work on it (and bear in mind your\nbranch doesn't need the same name or to be related in any long term way;\nyou are merely using their remote branch as a starting point for your\nbranch).\n\n-Peff\n"},{"id":"121743","messageId":"20090825183230.GB23731@coredump.intra.peff.net","threadId":"20731","inReplyTo":"8E2E19AE-DFA6-4000-AD73-35739F1E6642@uchicago.edu","subject":"Re: Confused about push/pull of a branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-25T18:32:30Z","receivedAt":"2009-08-25T18:32:30Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 25, 2009 at 12:58:25PM -0500, Fritz Anderson wrote:\n\n> >I can't get a second machine to pull in a branch that's in my\n> >remote repository. I'm confused.\n> \n> And just from half-wittedly fooling around, I tried:\n> \n> machine_2$ git pull origin webservices\n\nThat will merge the 'webservices' branch from your origin with your\ncurrent branch (which looks like 'master' in this case).\n\nRemember that \"pull\" in git is really just \"fetch\" and \"merge\". What you\nwant is \"fetch\" and \"create a new local branch\":\n\n  $ git fetch\n  $ git checkout -b webservices origin/webservices\n\nexcept that the \"fetch\" step has probably already been done as a\nside-effect of the pull you did earlier.\n\n> This seems to mean that master on machine_2 is now congruent to\n> webservices on machine_1. That's not what I meant. Is there a way to\n> undo this? git-pull origin-master doesn't seem to do anything.\n\nSort of. It contains all the changes of 'master' _and_ all the changes\nof 'webservices'. However in this case there were no changes in 'master'\nthat were not already in 'webservices', so we were able to \"fast\nforward\" to where webservices is. If the two branches had diverged at\nall, you would have had a merge (potentially with conflicts).\n\nTo undo it, you probably want:\n\n  $ git checkout master ;# make sure we are on master branch\n  $ git reset --hard origin/master ;# go back to where remote master is\n\n-Peff\n"}]}