From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: "Joachim Schmitz" <jojo@schmitz-digital.de>
Cc: git@vger.kernel.org
Subject: Re: How to update a cloned git repository
Date: Tue, 11 Sep 2012 13:06:08 +0200 [thread overview]
Message-ID: <vpq7gs0es4f.fsf@bauges.imag.fr> (raw)
In-Reply-To: <k2n4v2$88t$1@ger.gmane.org> (Joachim Schmitz's message of "Tue, 11 Sep 2012 12:49:01 +0200")
"Joachim Schmitz" <jojo@schmitz-digital.de> writes:
> Hi folks
>
> Probably a beginner's question...
>
> If I did a
> git clone git://guthub.com/git/git.git
> and worked on some own branches of pu
> git checkout pu;git checkout -p mybranch;
I guess you meant "git checkout -b mybranch" (not -p).
> hack;hack;...;git commit -a -s
>
> how to update my repository once the the one on github changed? A
> plain git pull or git fetch;git merge keeps failing on my with lots of
> conflicts, none of which relate to any of the changes I did (and hence
> wouldn't know how to resolve)
Short answer: don't work on pu. Work on master unless you have a good
reason not to.
Longer answer: the pu branch in git.git is often re-written, hence the
commit on which you started hacking once existed in git.git's pu, but it
probably no longer is.
You cloned this:
--A---B---C <-- origin/pu
Hacked to this
origin/pu
|
v
--A---B---C---D---E <-- mybranch
and the next fetch resulted in something like this:
B'---C'---D'---F <-- origin/pu
/
--A---B---C---D---E <-- mybranch
while you could have expected that if origin/pu had just been
fast-forwarded with a new commit F:
F <-- origin/pu
/
--A---B---C---D---E <-- mybranch
As a result, "git merge" computes a common ancestor very far backward in
history. Instead of merging only your changes with new pu content, it
merges the old history of pu (plus your changes) with the new history of
pu, and you get spurious conflicts.
The solution is to rebase your changes (and only yours). My advice is to
rebase them on master, like this (replace 42 by the number of commits
you want to rebase in HEAD~42):
git rebase HEAD~42 --onto origin/master
Once you did this, you can start using "git pull" (or "git pull
--rebase") as usual.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2012-09-11 11:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-11 10:49 How to update a cloned git repository Joachim Schmitz
2012-09-11 11:06 ` Matthieu Moy [this message]
2012-09-11 11:17 ` Joachim Schmitz
2012-09-11 11:21 ` Matthieu Moy
[not found] ` <007001cd9016$8f980f80$aec82e80$@schmitz-digital.de>
2012-09-11 12:40 ` Matthieu Moy
2012-09-11 12:48 ` Joachim Schmitz
2012-09-11 13:07 ` Erik Faye-Lund
2012-09-11 16:05 ` Junio C Hamano
2012-09-11 16:21 ` Matthieu Moy
2012-09-11 16:46 ` Joachim Schmitz
2012-09-12 8:52 ` Matthieu Moy
2012-09-11 14:09 ` Sitaram Chamarty
2012-09-11 16:00 ` Junio C Hamano
2012-09-11 16:45 ` Joachim Schmitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpq7gs0es4f.fsf@bauges.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=jojo@schmitz-digital.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.