问题描述
我正在使用SourceTree和Git-Flow模式.现在,我已经准备好发布版本供我的Beta测试人员进行测试,因此我创建了一个新的release/v1.0.1
分支.但是我的想法有所下滑,即使没有将发行版发送给测试人员,我还是决定完成发行版(合并到develop
和master
并标记).因此,如果测试人员发现任何错误,我都可以在发布分支中修复这些错误,那么我希望再次打开发布分支.然后,在修复所有错误之后,我就可以完成发布.
I'm using SourceTree and Git-Flow pattern. Now I have prepared a release for my beta-testers to test so I created a new release/v1.0.1
branch. But my mind slipped and I decided to finish (merge into develop
and master
and tag) the release even though I haven't even sent out the release to my testers. So I would like to have the release branch open up again if my testers finds any bugs I can fix these bugs in the release branch and then when all bugs are fixed I can finish the release.
那么,如何最好使用SourceTree(或使用git命令)轻松地恢复到具有release/v1.0.1
分支的状态?
So how can I easily with SourceTree preferably (or using git commands) revert back to the state when I had the release/v1.0.1
branch?
从SourceTree附加的屏幕转储:
Attached screendump from SourceTree:
编辑:好的,我在develop
(HEAD〜2)上执行了git reset --hard HEAD~2
,因为我已经进行了手动检出测试.但是现在当我结帐master
并执行git reflog
时,在我看来我应该在HEAD〜6
Okay I did the git reset --hard HEAD~2
on develop
(HEAD~2) because I had tested manually checking out. But now when I checkout master
and do a git reflog
it seems to me that I should do a reset on HEAD~6
Peters-MacBook-Pro:Remessage peterwarbo$ git reflog
f7663b1 HEAD@{0}: checkout: moving from develop to master
3d132da HEAD@{1}: reset: moving to HEAD~2
2f1c753 HEAD@{2}: checkout: moving from master to develop
f7663b1 HEAD@{3}: checkout: moving from develop to master
2f1c753 HEAD@{4}: merge release/v1.0.1: Merge made by the 'recursive' strategy.
4332fe4 HEAD@{5}: checkout: moving from master to develop
f7663b1 HEAD@{6}: merge release/v1.0.1: Merge made by the 'recursive' strategy.
fe323ef HEAD@{7}: checkout: moving from release/v1.0.1 to master
28a63ea HEAD@{8}: commit: Bumped version number to 1.0.1
但是当我这样做的时候,我得到了这个错误":
But when I do that I get this "error":
Peters-MacBook-Pro:Project peterwarbo$ git reset --hard HEAD~6
fatal: ambiguous argument 'HEAD~6': unknown revision or path not in the working tree.
用于说明他妈的的新图片.
EDIT 2: New image to illustrate fuckup.
在user1615903的答案中发出git命令后,附加了新图像以说明当前状态.为什么说发展落后2?为什么即使我将主节点重置为初始提交(fe323ef
),为什么仍要从release/v1.0.1
合并到主节点?
EDIT 3: Attached new image to illustrate the current state now after issuing the git commands in user1615903´s answer. Why does it say that develop is 2 behind? And why is there a merge from release/v1.0.1
to master even though I did a reset to master to the initial commit (fe323ef
)?
推荐答案
这很容易.您需要做的事情是:
This is quite easy. Things you will need to do are:
-
将develop分支重置为合并之前的提交
Reset develop branch to the commit it was before merge
将master分支重置为合并之前的提交
Reset master branch to the commit it was before merge
再次将发布分支指向正确的提交
Have the release branch point to the correct commit again
删除标签
将固定提交推送到远程
执行第1步和第2步:
git checkout develop
git reset --hard 4332fe4
git checkout master
git reset --hard <SHA of the commit the master was before the merge>
然后重新创建"发行分支:
Then to "recreate" the release branch:
git checkout -b "release/v1.0.1" 28a63ea
最后删除标签:
git tag -d v1.0.1
之后,如果更改已经被推送,则需要使用-f开关来覆盖远程更改:
After that, if the changes were already pushed, you need to use the -f switch to override changes in remote:
git push -f
并从远程删除标签:
git push --delete origin v1.0.1
这篇关于还原合并Git-Flow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!