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

Re: Confused about push/pull of a branch

From
Jeff King <peff@peff.net>
Date
Aug 25, 2009, 18:32 UTC
Message-ID
<20090825183230.GB23731@coredump.intra.peff.net>
In-Reply-To
<8E2E19AE-DFA6-4000-AD73-35739F1E6642@uchicago.edu>
On Tue, Aug 25, 2009 at 12:58:25PM -0500, Fritz Anderson wrote:
Show 6 quoted lines
> >I can't get a second machine to pull in a branch that's in my
> >remote repository. I'm confused.
> 
> And just from half-wittedly fooling around, I tried:
> 
> machine_2$ git pull origin webservices

That will merge the 'webservices' branch from your origin with your current branch (which looks like 'master' in this case).

Remember that "pull" in git is really just "fetch" and "merge". What you want is "fetch" and "create a new local branch":

  $ git fetch
  $ git checkout -b webservices origin/webservices

except that the "fetch" step has probably already been done as a side-effect of the pull you did earlier.

> This seems to mean that master on machine_2 is now congruent to
> webservices on machine_1. That's not what I meant. Is there a way to
> undo this? git-pull origin-master doesn't seem to do anything.

Sort of. It contains all the changes of 'master' _and_ all the changes of 'webservices'. However in this case there were no changes in 'master' that were not already in 'webservices', so we were able to "fast forward" to where webservices is. If the two branches had diverged at all, you would have had a merge (potentially with conflicts).

To undo it, you probably want:
  $ git checkout master ;# make sure we are on master branch
  $ git reset --hard origin/master ;# go back to where remote master is
-Peff
Previous: Fritz AndersonNext: Jeff King
Message 4 of 5 in “Confused about push/pull of a branch”
  1. Fritz AndersonAug 25, 2009
  2. Fritz AndersonAug 25, 2009
  3. Fritz AndersonAug 25, 2009
  4. Jeff KingAug 25, 2009
  5. Jeff KingAug 25, 2009

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.