从失败的rebase恢复 [英] Recovering from a failed rebase

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

问题描述

我使用 git svn 来获得公司规定的svn服务器的一些git善良。我刚刚发生了一次严重的错误,我试图找出恢复的最佳方式。



以下是发生的情况:


  1. 首先,我有这个

       - -1(主)
    \ - B - C - D - E(功能/修复部件)


  2. 然后我做了 git checkout master 然后 git svn rebase 我没有预料到我的功能分支和主人之间会有什么冲突,因为这些更改是在一个完全不同的文件夹中的。所以在这一点上,我想我有这个:

      --- 1--2--3--4(master)
    \\ - B - C - D-- E(feature / fix-widgets)

    其中 1--2-- 3 - 4 是从svn提交的提交。

  3. 下一步我做 git checkout feature / fix -widgets ,然后 git rebase master 。立即出现冲突,有些事情没有加起来,所以我决定溜走,更仔细地看待事情。我做了 git rebase --abort ,希望这会使我恢复到之前的状态。


  4. <

      > $ git rebase --abort 
    错误:git checkout-index:无法创建文件somedir / somefile.cs(权限被拒绝)
    致命:无法将索引文件重置为修订版本'be44daa05be39f6dd0d602486a598b63b6bd2af7'。


  5. 现在我不知道该怎么做。 git status 表明我在 feature / fix-widgets 中,但是我有一大堆阶段性变化,以及之前提交的大量未跟踪文件。如果我可以找回 E



解决方案

你应该看看 ORIG_HEAD


ORIG_HEAD HEAD 的前一状态,由可能具有危险行为的命令设置,以便于恢复它们。

现在Git的reflog不太有用: HEAD @ {1} 大致等于 ORIG_HEAD HEAD @ {1} 总是 HEAD 的最后一个值, ORIG_HEAD HEAD 在危险操作之前的最后一个值)

所以试试这个 git reset 可以恢复到之前的状态任何rebase:

  git reset --hard ORIG_HEAD 


I'm using git svn to get some git goodness with the company-mandated svn server. I just had a rebase go horribly awry, and I"m trying to figure out the best way to recover.

Here's what happened:

  1. To start with, I had this

    ---1 (master)
        \--B--C--D--E (feature/fix-widgets)
    

  2. So then I did git checkout master and then git svn rebase on master to pull down those commits. I did not anticipate any conflicts between my feature branch and the master, because the changes were in a totally different folder. So at this point, I think I have this:

    ---1--2--3--4 (master)
        \--B--C--D--E (feature/fix-widgets)
    

    Where 1--2--3--4 are commits pulled in from svn.

  3. Next I do git checkout feature/fix-widgets and then git rebase master. There's immediately a conflict, and some things that don't add up, so I decide to slink away and look at things more carefully. I do git rebase --abort, hoping this will restore me to where I was before the rebase.

  4. I do git rebase --abort and receive the following message

    $ git rebase --abort
      error: git checkout-index: unable to create file somedir/somefile.cs (Permission denied)
      fatal: Could not reset index file to revision 'be44daa05be39f6dd0d602486a598b63b6bd2af7'.
    

  5. Now I'm not sure what to do. git status shows that I'm on feature/fix-widgets, but I have a whole bunch of staged changed, and a large number of untracked files, which were previously committed. I'd be fine if I could get back E.

解决方案

You should have a look at ORIG_HEAD

ORIG_HEAD is previous state of HEAD, set by commands that have possibly dangerous behavior, to be easy to revert them.
It is less useful now that Git has reflog: HEAD@{1} is roughly equivalent to ORIG_HEAD (HEAD@{1} is always last value of HEAD, ORIG_HEAD is last value of HEAD before dangerous operation)

So try this git reset to get back to before any rebase:

git reset --hard ORIG_HEAD   

这篇关于从失败的rebase恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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