【发布时间】:2018-06-05 03:25:29
【问题描述】:
在git rebase 操作之后,有没有办法恢复和恢复git rebase 操作?
在以下变基输出之后我做了一个git rebase --abort:
On branch feature/cool-feature-x
Last commands done (20 commands done):
pick bd4c3q commitA
pick e53wr1 commitB
(see more in file .git/rebase-merge/done)
Next commands to do (7 remaining commands):
pick ws5b4 update
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'feature/cool-feature-x' on 'as34y5'.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
git log: 按预期给了我一个较旧的提交。说最后一次提交,即last-working-commit
git reflog 具有预期的所有历史记录。我想用HEAD{2}
git reset --hard HEAD{2} 我所做的最后一次更改给了我这个:
warning: Log for ref HEAD unexpectedly ended on Sun, 5 Jun 2018 16:15:19
+0300 (last time I made the changes before `git rebase --abort`)
但是last-working-commit 还是一样的。每次我运行相同的命令时,我都会在日志中得到多个last-working-commit
参考问题: Undoing a git rebase
Git: how to undo merge during rebase
编辑:
git reset 似乎在发出警告后仍然有效。它每次都创建相同的最后一次提交,但是在切换回我最初执行rebase 的分支后,HEAD 实际上已按我的意愿重置。我不知道它为什么会这样,并且有那个警告。
【问题讨论】: