Git:变基失败后恢复分歧的存储库

发布于 2024-09-27 14:42:10 字数 338 浏览 0 评论 0原文

我运行了 git pull --rebase ,并在使用 git rebase --abort 修复了几个合并冲突后中止了此操作。

在尝试 rebase 之前,git status 告诉我:“您的分支比‘origin/master’领先 20 次提交。” 现在我得到:“你的分支和‘origin/master’已经分歧,并且分别有 15 和 5 个不同的提交。”

我已经重置到最新提交(git reset --hard c15...e30),但状态消息仍然相同。

如何将我的存储库恢复到开始混乱之前的状态?而现在的状态和之前有什么区别呢?

谢谢。

I ran a git pull --rebase, and aborted this after fixing several merge-conflicts using git rebase --abort.

Before the attempted rebase, git status told me: "Your branch is ahead of 'origin/master' by 20 commits."
Now I get: "Your branch and 'origin/master' have diverged, and have 15 and 5 different commit(s) each, respectively."

I have already done a reset to the latest commit (git reset --hard c15...e30), but the status message is still the same.

How do I revert my repository to the state is was before I started the mess? And what is the difference between the current state and the previous?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄司 2024-10-04 14:42:10

git rebase --abort 应该已经带你回到原来的 HEAD 了。我不确定“使用...中止修复多个合并冲突”是什么意思。您的意思是--继续吗?

无论如何,现在要做的就是查阅转发日志。引用日志是您所有引用所在位置的本地临时日志。如果您查看 .git/logs/HEAD,您可以看到 HEAD(工作集)所在的位置。在 .git/logs/refs/... 下,您可以看到所有分支(本地和远程)的位置。日志中的每一行都反映了一些操作。起始 SHA、结束、用户、时间以及描述导致更改的操作的字符串。您可以找到您想要的那个并重置回到它。

The git rebase --abort should have taken you back to your original HEAD. I'm not sure what you meant by "fixing several merge-conflicts using ... abort". Did you mean --continue?

Anyway, the thing to do now is consult the reflog. The reflog is a local, temporal log of where all of your references have been. If you look at .git/logs/HEAD you can see where HEAD (the working set) has been. Under .git/logs/refs/... you can see where all of your branches (local and remote) have been. Each line in the log reflects some action. The starting SHA, ending, user, time, and a string describing what action caused the change. You can find the one you want and reset back to it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文