撤消 git merge(尚未推送)
我只是将一些更改提交到我的功能分支之一(“feedback_tab”),然后签出“master”并将它们合并到那里。我实际上打算将它们合并到我的“开发”分支中。
现在,master 领先于“origin/master”(其远程)17 个提交 - 我还没有推动合并(显然也不想这样做)。如何将 master 恢复到意外合并之前的状态?我对 git revert
和 git Reset
与这些东西感到困惑。
我查看了 git 日志,没有将 Feedback_tab 合并到 master 的条目。我以为这会是顶部条目?
有点困惑:/欢迎任何帮助!最大限度
I just committed some changes into one of my feature branches ("feedback_tab") then, checked out "master" and merged them in there. I actually meant to merge them into my "development" branch.
Now, master is ahead of 'origin/master' (its remote) by 17 commits - I haven't pushed the merge up (and don't want to, obviously). How can I revert master back to the same state as before the accidental merge? I'm confused between git revert
and git reset
with this stuff.
I looked in my git log and there's no entry for merging feedback_tab into master. I'd have thought it would be the top entry?
Bit confused :/ any help welcome! max
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要撤消未推送的合并:
如果在合并期间发生冲突,撤消合并的最佳方法是:
To undo a merge that was NOT pushed:
If during the merge you get a conflict, the best way to undo the merge is:
git reset --hard HEAD~17
让您比 master 的 head 早 17 个提交。 git rebase -i HEAD~17 可能也摆脱了额外的提交。git reset --hard HEAD~17
takes you back 17 commits ahead of the head of master.git rebase -i HEAD~17
probably gets rid of the extra commits as well.摘自git重置
Taken from git reset
这个一定会成功的!
第一个将恢复您最近所做的更改(合并)
第二个会将存储库初始化为最新版本(因此将快进到原始版本的最新版本)
我已经尝试过
,但没有成功。
This one will surely work!
The first one will revert the changes you recently made (the merge)
the second will init the repo to latest (therefore will fast forward to latest on origin)
I've tried
but it didn't do the trick.