【问题标题】:git reset --hard error after git rebase abort: warning: Log for ref HEAD unexpectedly ended on DD/MM/YYY TTTTgit rebase abort 后的 git reset --hard 错误:警告:ref HEAD 的日志在 DD/MM/YYY TTTT 上意外结束
【发布时间】: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 实际上已按我的意愿重置。我不知道它为什么会这样,并且有那个警告。

【问题讨论】:

    标签: git rebase abort


    【解决方案1】:

    如您所见,此警告不会阻止重置工作。

    它(警告信息“warning: Log for ref HEAD unexpectedly ended on...”)来自refs.c#write_pseudoref()

    tested here:

    test_expect_success 'Query "master@{2005-05-28}" (past end of history)' '
        test_when_finished "rm -f o e" &&
        git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
        test $D = $(cat o) &&
        test "warning: Log for ref $m unexpectedly ended on $ld." = "$(cat e)"
    

    这意味着,在某个时刻,Git 正在检查 HEAD 的日志,同时它正在重置,并认为所述日志“超过了它引用的上一个分支的(重置)历史记录的结尾”。
    重置完成后,我希望 git 日志再次连贯(带有新的“历史结束”)

    【讨论】:

    • 谢谢哥们。当我没有得到任何东西时,那是因为它正在重置,对吧?
    • 是的,我怀疑是这样的。
    猜你喜欢
    • 2018-01-13
    • 1970-01-01
    • 2011-02-09
    • 2011-08-19
    • 2014-08-25
    • 2019-09-05
    • 2019-12-31
    • 1970-01-01
    相关资源
    最近更新 更多