Re: Confused about push/pull of a branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 25, 2009 at 12:58:25PM -0500, Fritz Anderson wrote:

> >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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]