使用撤消git rebase [英] Undo a git rebase using onto

查看:146
本文介绍了使用撤消git rebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令将我的分支版本2 重新分配给master:

  git rebase  - 主版本1版本2 

如何撤销此操作?



为了取消它,我做了 git reflog



目前,

 <$ c  $ c>你的分支和'origin / version2'分别有
和2563和222个不同的提交。
没有提交(工作目录干净)

我想撤销这个rebase。假设你没有修改 version2 分支,因为你已经重新设计了这个分支,您只需使用< reference> @ {n} 语法将分支硬重置到其先前的第一个位置,其中 n 是引用的前N位:

  git checkout version2 
git reset - -hard version2 @ {1}


I rebased my branch version2 against master using:

git rebase --onto master version1 version2

How can I undo this?

To undo it I did git reflog

Currently, git status (on version2) gives me :

Your branch and 'origin/version2' have diverged,
and have 2563 and 222 different commits each, respectively.
nothing to commit (working directory clean)

I want to undo this rebase.

解决方案

Assuming you haven't modified the version2 branch since you rebased it, all you need to do is a hard reset of the branch to its 1st prior position, using <reference>@{n} syntax, where n is the Nth prior position of the reference:

git checkout version2
git reset --hard version2@{1}

这篇关于使用撤消git rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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