What does cherry-picking a commit with Git mean?

前端 未结 12 2349
梦毁少年i
梦毁少年i 2020-11-22 11:58

Recently, I have been asked to cherry-pick a commit.

So what does cherry-picking a commit in git mean? How do you do it?

12条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 12:11

    Cherry picking in Git is designed to apply some commit from one branch into another branch. It can be done if you eg. made a mistake and committed a change into wrong branch, but do not want to merge the whole branch. You can just eg. revert the commit and cherry-pick it on another branch.

    To use it, you just need git cherry-pick hash, where hash is a commit hash from other branch.

    For full procedure see: http://technosophos.com/2009/12/04/git-cherry-picking-move-small-code-patches-across-branches.html

提交回复
热议问题