git cherry-pick problem?
世界只因有你
世界只因有你 2017-05-02 09:32:56
0
2
685

Create a new warehouse, put only one text file in it, and make 6 commits respectively. At this time, git log --oneline should look like this

The content of the file is as follows

I want to discard the 442452d commit but keep the e09949e commit, here's how I do it
git reset --hard 260effc
Then git cherry-pick e09949e

A conflict broke out at this time, as shown below

What I don’t understand is why there is a conflict. It should be patched directly. It shouldn’t look like the picture above. e09949e’s submission should only contain ‘4’ and not ‘3’. If it is still needed If '3' is removed manually, what's the point of cherry-pick? I can just go into the file and delete it. Or is there something wrong with my usage? Ask God for guidance! ! !

世界只因有你
世界只因有你

reply all(2)
Ty80

Why not just git revert 442452d?

Commit records relative modifications and is related to the upper and lower lines of the modified content. If the previous line is lost, a conflict will be reported and needs to be resolved manually. If your two commits are no longer in related functions, you can revert directly.

In addition, using this method of reset --hard and then cherry-pick is not very good. Other collaborators may have added other commits in the middle, making subsequent conflict handling more difficult.

A better usage scenario for cherry-pick is when you want a separate feature from another branch on one branch.

漂亮男人

Because of the difference in e09949e只包含4,是针对前一个commit442452d.

But if you put 442452d给去掉了,希望把e09949e的父节点从442452d指到260effc now, there will indeed be conflicts.

I’m not sure if my explanation is clear without moving pictures. If you have any questions, I suggest you play this tutorial first.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template