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

新建一个仓库,里面只放一个文本文件,分别做6次提交,,此时git log --oneline 的样子应该是这样的

文件的内容是这样的

我要丢弃 442452d 提交,但保留e09949e提交,我的做法是这样的
git reset --hard 260effc
然后 git cherry-pick e09949e

此时爆冲突了,如下图

我不理解的是为何会冲突,按道理应该直接就patch了,不应是上图的样子,e09949e这次提交应该是只包含‘4’ 不包含 ‘3’吧,如果要是还需要手动去掉‘3’的话,那cherry-pick 还有啥意义呢,我直接进文件把它删掉就好了啊,还是我用法有问题?求大神指点!!!

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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!