On Thu, 10 Mar 2016 23:27:01 +0100
Pablo Rodríguez <oi...@web.de> wrote:

> > If we suppose we're talking about the branch "master", and the
> > remote server is known as "origin", then you'd do something like
> > this:
> > 
> > First do
> > 
> >     git fetch origin
> > 
> > to have origin/master updated to the state of "master" at "origin".
> > 
> > Then either do
> > 
> >     git branch temp master
> Probably I prefer creating a branch. But isn’t it better to create the
> branch before fetching contents from the remote server?

It's irrelevant: the command above creates a local branch named "temp"
which points to the same commit a local branch "master" currently
points at.  That is, at this point, the data from the remote server is
not involved at all.  The reason for the execution of this command is
to have "something" -- a branch in this case -- to point to whatever
"master" currently points at.  This is needed because we're about to
"retarget" the branch "master" with the next few commands.

> > Next, reset your local "master" to "origin/master":
> > 
> >     git checkout master
> >     git reset --hard origin/master

This `git reset` command accesses the so-called "remote-tracking branch"
named "origin/master" which does indeed track the state of the "master"
branch as found in the remote repository known as "origin".  To have it
in an up-to-date state, running `git fetch` is needed.  So, fetching
the contents from the remote repository is needed before running this
command.  Contrary to this, operations which only touch local branches
do not care about the state of the remote repository.

> > You might also consider rebasing.  If your original problem was to
> > deal with the case where you have a series of local commits on a
> > branch you'd like to push "upstream" but the upstream version of
> > your branch got updated so your commits can't be used to
> > fast-forward it (don't push cleanly) then you might use `git
> > rebase`:
> Fine, but too complex for me. And origin hasn’t been updated.

That's a bit surprising to read because, as I understood it, your
situation was exactly the "origin" having been updated compared to your
local case. ;-)

I'd honestly recommend you to read a book on Git: it helps to have a
clear vision of what a tool can do for you, so, when confronting with a
problem you have a good overview of which methods can be used to deal
with it.  Please refer to [1] (other good books exist as well).

1. http://git-scm.com/book

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to