从失败的rebase恢复 [英] Recovering from a failed rebase
问题描述
我使用 git svn
来获得公司规定的svn服务器的一些git善良。我刚刚发生了一次严重的错误,我试图找出恢复的最佳方式。
以下是发生的情况:
-
首先,我有这个
- -1(主)
\ - B - C - D - E(功能/修复部件)
-
然后我做了
git checkout master
然后git svn rebase
我没有预料到我的功能分支和主人之间会有什么冲突,因为这些更改是在一个完全不同的文件夹中的。所以在这一点上,我想我有这个:--- 1--2--3--4(master)
\\ - B - C - D-- E(feature / fix-widgets)
其中
1--2-- 3 - 4
是从svn提交的提交。 下一步我做 - <
> $ git rebase --abort
错误:git checkout-index:无法创建文件somedir / somefile.cs(权限被拒绝)
致命:无法将索引文件重置为修订版本'be44daa05be39f6dd0d602486a598b63b6bd2af7'。
-
现在我不知道该怎么做。
git status
表明我在feature / fix-widgets
中,但是我有一大堆阶段性变化,以及之前提交的大量未跟踪文件。如果我可以找回E
。
git checkout feature / fix -widgets
,然后 git rebase master
。立即出现冲突,有些事情没有加起来,所以我决定溜走,更仔细地看待事情。我做了 git rebase --abort
,希望这会使我恢复到之前的状态。
你应该看看 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:
To start with, I had this
---1 (master) \--B--C--D--E (feature/fix-widgets)
So then I did
git checkout master
and thengit 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.Next I do
git checkout feature/fix-widgets
and thengit 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 dogit rebase --abort
, hoping this will restore me to where I was before the rebase.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'.
Now I'm not sure what to do.
git status
shows that I'm onfeature/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 backE
.
You should have a look at ORIG_HEAD
ORIG_HEAD
is previous state ofHEAD
, 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 toORIG_HEAD
(HEAD@{1}
is always last value ofHEAD
,ORIG_HEAD
is last value ofHEAD
before dangerous operation)
So try this git reset
to get back to before any rebase:
git reset --hard ORIG_HEAD
这篇关于从失败的rebase恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!