问题描述
正如您在图片中看到的那样,我当时正在使用功能forum_kolo_3,我决定完成该功能并将其合并以进行开发(但并未将更改推送到远程开发,因此它只是本地更改),然后我意识到这是个坏主意,现在我想删除此合并,就像从未发生过一样.
As you can see in the picture, I was working in feature forum_kolo_3, I decided to finish that feature and merge it to develop (but did not pushed the changes to remote develop, so its just local changes) and than I realized it was a bad idea and now I want to remove this merge, like it never happened.
类似于此处所述的情况:
So similar situation as described in here:git revert not allowed due to a merge but no -m option was given
但是我不太确定现在要做什么,撤消还是重置?我想撤消刚刚做的合并.
But Im not quite sure what to do now, reverse or reset?I want to undo the merge I just did.
我还发现了如何还原git仓库到以前的提交了吗?
git commit
git commit
这似乎是个更好的主意...但我不知道
Which seems like a better idea...but I have no clue
推荐答案
在合并之前仅找到developer分支的最后一次提交,然后将git历史记录重置为该提交.
Just find the last commit of the develop branch before merge, and then reset your git history to that commit.
git reset --hard <pre_merge_last_commit_id>
您可以使用gitk
或git log --oneline --decorate=full --graph
之类的图形工具来查找developer分支的最后一次提交.
You can use graphical tool like gitk
or git log --oneline --decorate=full --graph
to find the last commit of the develop branch.
注意:请确保不要重置为功能分支的最后一次提交.
Note: Make sure you don't reset to the last commit of the feature branch instead.
这篇关于GitHub恢复还是重置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!