Git: Recover from failed rebase

亡梦爱人 提交于 2020-01-15 04:24:13

问题


I just tried to rebase one of my feature-branches and something went wrong - now i am trying to figure out how to undo this.

Being on my feature-branch i simply did a: git rebase develop after committing a bugfix on develop which i wanted in the feature-branch as well. This gave me:

$ git rebase develop
First, rewinding head to replay your work on top of it...
Rename from '.git/HEAD.lock' to '.git/HEAD' failed. Should I try again? (y/n)? n

error: Couldn't set HEAD
fatal: Cannot update the ref 'HEAD'.
could not detach HEAD

Well, now i see a bunch of staged files on this branch, but it seems that all commits on this branch are still intact (at least i am not missing one :)

I want to revert this branch to how it looked like before the rebase-attempt. Unfortunately it seems that ORIG_HEAD was not correctly set before the rebase, since i can see it being shown next to a commit on another feature-branch (which i rebased before trying to rebase this feature-branch).

Is a reset to the last visible commit on my current feature-branch the way to go?

--qu


回答1:


You can use git reflog to see the what commit it was, copy commit number for there and do git reset --hard <number>



来源:https://stackoverflow.com/questions/9481735/git-recover-from-failed-rebase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!