简体   繁体   English

从本地历史记录中删除git merge commit

[英]Delete git merge commit from local history

My commit history looks like this: 我的提交历史记录如下:

提交历史

Yellow is the master branch, blue and purple are feature branches. 黄色是主分支,蓝色和紫色是特征分支。 Commits 0-5 have been pushed, commits 6-10 are only local. 提交0-5已被推送,提交6-10仅在本地。

I want to undo the effect of merge commit 6, I mean delete it entirely, and reroute C7 to be the merge of C1 and C2. 我想撤消合并提交6的影响,我的意思是将其完全删除,然后将C7重新路由为C1和C2的合并。

Any ideas on how to achieve this? 关于如何实现这一目标的任何想法?

This won't be very easy, and since you will need some trial and error, better take a (local) copy of you git repo before doing this. 这将不是一件容易的事,并且由于您将需要一些反复试验,因此在执行此操作之前最好先制作一份git repo的(本地)副本。 Then try something like this: 然后尝试这样的事情:

git branch temp <sha-2>
git merge <sha-1>
git merge <sha-5>
git checkout master
git rebase temp
git branch -d temp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM