Stuck in a git rebase ... how to reset

Sim*_*ods 10 git rebase

I am part way through a git rebase and I am stuck. I can't remember exactly what happened but I was using a UI and deleted a checked-out branch and things just seemed to go blank. I restarted and managed to do a bit of other work creating and committing to other branches etc but then I noticed a status saying I was still in the middle of a rebase

If I try

git rebase --skip
git rebase --continue
git rebase --abort
Run Code Online (Sandbox Code Playgroud)

each fail with

error: could not read '.git/rebase-merge/head-name': No such file or directory
Run Code Online (Sandbox Code Playgroud)

Is there a way I can get back to a stable state? I'm really not bothered about what the rebase related to so am not trying to get back to point where I am still in the middle of the rebase.

Edit:

$ git status
On branch fix/SJW-01225
Your branch is up to date with 'core-v3/fix/SJW-01225'.

You are currently rebasing.
(all conflicts fixed: run "git rebase --continue")

Untracked files:
(use "git add <file>..." to include in what will be committed)

     [long list of untracked files]

nothing added to commit but untracked files present (use "git add" to track)
Run Code Online (Sandbox Code Playgroud)

Edit-1:

$ touch .git/rebase-merge/head-name

$ git rebase --abort
error: could not read '.git/rebase-merge/onto': No such file or directory

$ touch .git/rebase-merge/onto

$ git rebase --abort
error: could not get 'onto': ''
Run Code Online (Sandbox Code Playgroud)

Thx

leo*_*ers 18

git rebase --quit为我工作。


And*_*ton 13

我不知何故让我的回购进入相同的状态。就我而言,没有.git/rebase-merge目录,但我确实找到了一个rebase-apply目录。除了正在进行的 rebase 之外,它git status是干净的,所以我唯一需要做的就是摆脱奇怪的坏 rebase 状态是运行:

rm -rf .git/rebase-apply/
Run Code Online (Sandbox Code Playgroud)


now*_*wox 12

为了摆脱损坏,git rebase您可以执行以下操作

  1. 重置为已知状态。你可以找到从您提交您开始rebase使用git reflog

例如,reflog将为您提供以下内容。重新设定基准的起点是最后一个起点,rebase (start)或者rebase -i (start)您是否进行了交互式重新设定。这里是HEAD@{1}

$ git reflog
f10ccfed (HEAD) HEAD@{0}: rebase : fast-forward
383aa038 (origin/master, origin/HEAD) HEAD@{1}: rebase (start): checkout HEAD~10
0600cf7e (origin/Files, master, Files) HEAD@{4}: checkout: moving from master to Files
0600cf7e (origin/Files, master, Files) HEAD@{5}: commit: fixes
f10ccfed (HEAD) HEAD@{6}: commit: refactoring
Run Code Online (Sandbox Code Playgroud)

因此,您需要的是:

    git checkout master # assuming you were on master
    git reset --hard HEAD@{1}
Run Code Online (Sandbox Code Playgroud)
  1. 删除rebase-merge文件夹
    rm -rf .git/rebase-merge
Run Code Online (Sandbox Code Playgroud)

  • 在 Windows 中,我需要引用提交。`git reset --hard "HEAD@{1}"` (3认同)