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

Re: Pulling one commit at a time.

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 23, 2009, 22:33 UTC
Message-ID
<7vr5v2qhws.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20090824060710.6117@nanako3.lavabit.com>
Nanako Shiraishi <nanako3@lavabit.com> writes:
Show 21 quoted lines
> When your histories look like this:
>
>       A                 your 'master'
>      /
>  ---X---U---V---W---Y   public 'master' (your 'origin')
>
> ... you can fetch first.
>
>  git fetch origin
>
> Then look at the history in gitk
>
>  gitk master origin
>
> And find the commit you are interested in merging (U in the above
> picture). And merge it.
>
>  git merge origin~3
>
> Replace "origin~3" in the example above with whatever commit you want to
> merge the entire history leading to it.
A good description.  Thanks, Nana.

Novice readers should notice the careful wording used here. She says "merge the entire history leading to it" instead of simply "merge the commit". Merging a commit in git always means merging the entire history leading to that commit, so they mean the same thing to people who know git well, but it avoids a misunderstanding that, if you did

    $ git merge V

it might apply the effect of only V, ignoring what U did, on top of your current state A. It doesn't.

       A-------M         your 'master'
      /       / 
  ---X---U---V---W---Y   public 'master' (your 'origin')

To create a commit that has only the effect of a single commit, you would need to cherry-pick it.

    $ git cherry-pick V
will give you
       A-------V'        your 'master'
      /
  ---X---U---V---W---Y   public 'master' (your 'origin')
where "git diff A V'" is a moral equivalent of "git diff U V".
Previous: Nanako ShiraishiNext: Sanjiv Gupta
Message 6 of 20 in “Pulling one commit at a time.”
  1. Sanjiv GuptaAug 23, 2009
  2. Alex RiesenAug 23, 2009
  3. Adam BrewsterAug 23, 2009
  4. Sam VilainAug 23, 2009
  5. Nanako ShiraishiAug 23, 2009
  6. Junio C HamanoAug 23, 2009
  7. Sanjiv GuptaAug 24, 2009
  8. Kai BlinAug 24, 2009
  9. Sanjiv GuptaAug 24, 2009
  10. Sean EstabrooksAug 24, 2009
  11. Erik Faye-LundAug 24, 2009
  12. Erik Faye-LundAug 24, 2009
  13. Matthieu MoyAug 24, 2009
  14. skillzero@gmail.comAug 24, 2009
  15. Matthieu MoyAug 24, 2009
  16. David AguilarAug 24, 2009
  17. Sanjiv GuptaAug 24, 2009
  18. Matthieu MoyAug 24, 2009
  19. Avery PennarunAug 24, 2009
  20. Sanjiv GuptaAug 24, 2009

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.