GitHub恢复还是重置? [英] GitHub revert or reset?

查看:234
本文介绍了GitHub恢复还是重置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如您在图片中看到的那样,我当时正在使用功能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 restore --no-commit 0766c053..HEAD

git revert --no-commit 0766c053..HEAD

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>

您可以使用gitkgit 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恢复还是重置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆