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

Re: Beginner question on "Pull is mostly evil"

From
Jeff King <peff@peff.net>
Date
May 7, 2014, 17:04 UTC
Message-ID
<20140507170405.GA6224@sigill.intra.peff.net>
In-Reply-To
<0C723FEB5B4E5642B25B451BA57E2730751C2642@S1P5DAG3C.EXCHPROD.USA.NET>
On Wed, May 07, 2014 at 03:40:28PM +0000, Jim Garrison wrote:
Show 8 quoted lines
> During my initial self-education I came across the maxim "don't pull,
> fetch+merge instead" and have been doing that.  I think I followed
> most of the "pull is (mostly) evil" discussion but one facet still
> puzzles me: the idea that pull will do a merge "in the wrong
> direction" sometimes.
> 
> Do I understand correctly that this occurs only in the presence of
> multiple remotes?

No, it does not have to do with multiple remotes. It is about "X merged into Y" versus "Y merged into X". The ordering of parents in a merge doesn't matter for the merge result, but git must choose some order, and it always uses your current HEAD first, and then the commit you are merging second (and so on, in an octopus merge).

As a result, you can use "git log --first-parent" to follow the line of development that always got merged into. In a strict topic-branch workflow like git.git, this will show you just what happened on master: a linear sequence of merges of topic branches, with occasional direct-to-master commits like version bumps.

For an integrator who is pulling from other people, "git pull bob topic" from "master" does the right thing: master is the first parent, and topic is the second parent.

For somebody with a centralized repo who follows the "push was a non-fastforward, so pull then push" advice, the merge between their work and master will be "backwards". The merge commit will have upstream's work (i.e., "master") merged into their topic. Following --first-parent will walk down their work instead of the merge commits on master.

Does that explain it?
-Peff
Previous: David KastrupNext: Junio C Hamano
Message 3 of 11 in “Beginner question on "Pull is mostly evil"”
  1. Jim GarrisonMay 7, 2014
  2. David KastrupMay 7, 2014
  3. Jeff KingMay 7, 2014
  4. Junio C HamanoMay 7, 2014
  5. Jim GarrisonMay 7, 2014
  6. Junio C HamanoMay 7, 2014
  7. Stephen & Linda SmithMay 8, 2014
  8. How to keep a project's canonical history correct.Stephen P. Smith, May 9, 2014
  9. Stephen SmithMay 9, 2014
  10. Junio C HamanoMay 9, 2014
  11. Stephen & Linda SmithMay 10, 2014

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.