What are the differences between git cherry-pick and git show | patch -p1?

后端 未结 2 2121
渐次进展
渐次进展 2021-02-13 21:29

I ran into a situation where git cherry-pick X would have some conflicts, but also created extra inserts (when verified with git diff).

I then

2条回答
  •  既然无缘
    2021-02-13 21:55

    When you cherry-pick a commit, it commits the result using all the metadata of the commit, not just the diff it represents - you'll get the original commit message and author. Your patch pipeline will get you the working tree contents that you want, but then you'll have to commit it yourself, hopefully with git commit -c to copy the metadata like cherry-pick would have. Cherry-pick also has some additional options that could be helpful, and can accept multiple commits (perhaps specified as a rev-list range). patch obviously doesn't support any of that.

    I'm not sure about your assertion that the result was "cleaner". Are you suggesting that git applied the diff differently than patch did?

提交回复
热议问题