为什么最近 git rebase -i with squashes 会导致头部分离?它曾经用交互式 rebase 的结果更新我当前的分支。如何获得交互式 rebase 以停止去分离的 HEAD?
我一直使用 git rebase -i 来压缩我的提交,然后再从远程存储库中提取以简化处理来自 git pull 的任何 merge 冲突。我不必解决潜在的多个提交的冲突,而只需解决一个提交。
我使用的示例命令
# git rebase -i <tip of public branch> <my latest commit>
git rebase -i 380647533da 82f5ee67bed
在 vim 中编辑 rebase 交互后:
pick 3ec7c211c49 version1
s 82f5ee67bed some significant refactoring
编辑保存提交后的输出:
[detached HEAD ea50304796c] version1
Date: Thu Jun 6 17:04:36 2019 -0400
14 files changed, 213 insertions(+), 52 deletions(-)
create mode 100644 some file
create mode 100644 some file
create mode 100644 some file
Successfully rebased and updated detached HEAD.
这与类似的帖子不同
git rebase -i develop HEAD leads to Detached Head
因为提问者想知道如何解决该 ONE 实例的问题。答案是 git checkout -b branchName
。在这个问题中,我想知道为什么它最近开始发生在我身上,以及如何为所有 FUTURE 实例解决它。
这与类似的帖子不同 git rebase -i with squash cannot detach HEAD因为那里的错误信息是could not detach HEAD
最佳答案
syntax guide for git rebase
显示:
<em>git rebase</em> [-i | --interactive] [<options>] [--exec ] [--onto <newbase>] [<upstream> [<branch>]] <em>git rebase</em> [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>] --root [<branch>] <em>git rebase</em> --continue | --skip | --abort | --quit | --edit-todo | --show-current-patch
所以你的命令:
git rebase -i 380647533da 82f5ee67bed
提供380647533da
作为<upstream>
和 82f5ee67bed
作为<branch>
.
描述部分的第一段说:
If <branch> is specified, git rebase will perform an automatic
git checkout <branch>
before doing anything else. Otherwise it remains on the current branch.
所以,你的 git rebase
相当于:
git checkout 82f5ee67bed
git rebase 380647533da
第一个命令导致分离的 HEAD。当 rebase 完成时,分离的 HEAD 保持不变。
关于git - 为什么最近, git rebase -i squash 导致头部分离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56501682/