3
a1----a2----a3-----a4 (branchA)
      \
       \b1---b2---b3---b4----b5----b6 (branchB)

current I am in branchA(a4), if I do git cherry-pick b3

what happens? diff of b3 and b2 will be patched to a4?

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
Sato
  • 8,192
  • 17
  • 60
  • 115
  • 2
    Possible duplicate of [What does cherry-picking a commit with git mean?](http://stackoverflow.com/questions/9339429/what-does-cherry-picking-a-commit-with-git-mean) – Naman Jan 24 '17 at 03:39
  • It does what the [git book](https://git-scm.com/book/en/v2/Distributed-Git-Maintaining-a-Project#_rebase_cherry_pick) says it does. –  Jan 24 '17 at 04:07

1 Answers1

4

If there are no conflicts, then the history after cherry-pick b3 will be:

a1----a2----a3-----a4----b3' (branchA)
      \
       \b1---b2---b3---b4----b5----b6 (branchB)

where b3' is the same change as b3 but rebased against branchA.

If you have any conflicts, then the cherry-pick command will tell you so and prompt you to resolve the conflicts manually before committing b3'.

In particular, doing a cherry-pick b3 does not include the changes b1 and b2.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • `b3' is the same change as b3` means `diff of b3 and b2` or `diff of b3 and a2`? – Sato Jan 24 '17 at 01:22
  • @Sato: The "change" in `b3` is the difference between `b3` and `b2`. As I said, the changes made in `b1` and `b2` are not involved in the cherry-pick. – Greg Hewgill Jan 24 '17 at 02:49