git - cherry-pick - HOWTO / WHYTO

前端 未结 3 1537
梦谈多话
梦谈多话 2020-11-28 15:32

Problem: You want to test a feature someone has developed, but it only exists in a remote branch which is woefully out of date.

Source

3条回答
  •  萌比男神i
    2020-11-28 15:50

    Problem:
    You want to test a feature someone has developed, but it only exists in a remote branch which is woefully out of date.

    It solves the problem because:

    • you don't want to merge the old branch including commits which are no longer relevant in your current state of development
    • you don't want to rebase your branch on top of an old branch just to get that one commit.
    • you won't have to merge back your branch to that old branch

    The last point is important because the first drawback of cherry-picking is that it introduces duplicate commits. But in your case, it doesn't matter.

    The other drawback is that the commit you are cherry-picking might have functional dependencies based on previous commits (of that old branch).
    In other word, its code works only because of other codes of other older commits (which aren't cherry-picked).
    That can be trickier to detect.

提交回复
热议问题