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

RE: How to update a cloned git repository

From
Joachim Schmitz <jojo@schmitz-digital.de>
Date
Sep 11, 2012, 11:17 UTC
Message-ID
<006f01cd900e$fce59a60$f6b0cf20$@schmitz-digital.de>
In-Reply-To
<vpq7gs0es4f.fsf@bauges.imag.fr>
Show 18 quoted lines
> From: Matthieu Moy [mailto:Matthieu.Moy@grenoble-inp.fr]
> Sent: Tuesday, September 11, 2012 1:06 PM
> To: Joachim Schmitz
> Cc: git@vger.kernel.org
> Subject: Re: How to update a cloned git repository
> 
> "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).
Yes, of course...
Show 9 quoted lines
> > 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.

There are some changes in pu, that I need as the basis, namely my setitimer patch and my 2nd mkdir patch, which haven't yet made it into the master branch (and in the setitimer case not out of pu)

Show 38 quoted lines
> 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
For pu this would be similar?
> Once you did this, you can start using "git pull" (or "git pull
> --rebase") as usual.

Like this? git pull --rebase HEAD~42

So far I create patches, wiped out the entire repository, cloned, forked and applied the changes, pretty painful.
Previous: Matthieu MoyNext: Matthieu Moy
Message 3 of 14 in “How to update a cloned git repository”
  1. Joachim SchmitzSep 11, 2012
  2. Matthieu MoySep 11, 2012
  3. Joachim SchmitzSep 11, 2012
  4. Matthieu MoySep 11, 2012
  5. Sitaram ChamartySep 11, 2012
  6. Junio C HamanoSep 11, 2012
  7. Joachim SchmitzSep 11, 2012
  8. Matthieu MoySep 11, 2012
  9. Joachim SchmitzSep 11, 2012
  10. Erik Faye-LundSep 11, 2012
  11. Junio C HamanoSep 11, 2012
  12. Matthieu MoySep 11, 2012
  13. Joachim SchmitzSep 11, 2012
  14. Matthieu MoySep 12, 2012

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.