suppose I have cherry-picked the commit comm1
from the master branch
into branch foo
. Will the commit comm1
be removed from the branch master
after successful cherry-pick or it will be just copied into branch foo
?
Asked
Active
Viewed 8,742 times
10

Ronald
- 2,721
- 8
- 33
- 44
-
[A copy: cherry-pick is a new commit applying the same diff elsewhere](http://think-like-a-git.net/sections/rebase-from-the-ground-up/cherry-picking-explained.html). – coredump Feb 18 '16 at 09:27
-
2Possible 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) – coredump Feb 18 '16 at 09:28
-
1It will create new commit on foo branch and leave master intact. If you want more details check docs: https://git-scm.com/docs/git-cherry-pick – Piotr W Feb 18 '16 at 09:30
2 Answers
28
It will copy the commit's delta and create a new commit out of it in the active branch.
When you ask yourself questions about what Git
will modify or not, keep in mind that you can only modify the active branch. So if your active branch is development
and you are cherry-picking a commit from branch feature/test
, you can only modify development
and not feature/test
. This way, you can deduce that the commit in feature/test
will not be affected.

Thibault D.
- 10,041
- 3
- 25
- 56
-
4Not the commit's content, the commit's delta to is predecessor. In my opinion this is a huge difference. Cherry-Picking a commit containing file1 file2 file3 and adding file4 won't create file1-3 in a branch that does not contain them. It will only add file4 to this branch. Remember, commits are always snapshots of the whole repository, no delta. – BlackEye Feb 18 '16 at 16:58
-
3@BlackEye Thank you for correcting. In my head it's clear that what I call the commit's _content_ is the delta but it is the wrong terminology and it may confuse new git users. – Thibault D. Feb 19 '16 at 14:54
6
Simply saying it will merge the particular change (commit) into target branch. Merge doesn't affect the source branch so it will be definitely not deleted.
So when you do full merge later, git will already know that this change was already integrated and will skip it.

Zbynek Vyskovsky - kvr000
- 18,186
- 3
- 35
- 43