Git rebase 过程被分离的头卡住了
Git rebase process gets stuck with detached head
我正在尝试在某个项目上改写倒数第二个提交以修复 运行 git rebase -i HEAD~3
的拼写错误,(使用 "nano" 编辑器)然后更改默认值 pick
选项提交到 r
或 reword
(在初始变基文件 window 上),并且不修改任何其他内容。如果有用的话,我在 master
分支上做。
一旦我保存了文件,Git,它并没有像往常一样向我显示下一个变基 window 来为该提交选择一个新名称,而是它自己告诉我一个与该提交分离的 HEAD 状态,从那时起也显示在 git status
命令上,直到我键入 git checkout master
.
无论我尝试多少次,同样的事情都会发生。
附加说明:我之前通过 运行 单个命令将使用的编辑器更改为 "nano":git config --global core.editor nano
编辑:根据要求,这是 Git 在我保存 TODO 列表时给我的消息:
adrian$ git rebase -i HEAD~1
Note: checking out 'da91bbcedc78cb2ebcaa9dc51f38c8d0a550195d'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b
HEAD is now at da91bbc... Test message
This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout.
could not detach HEAD
此时运行git rebase --continue
后输出:
No rebase in progress?
当您将 edit
放入交互式变基的待办事项文件中时,分离的 HEAD 消息正常出现。您一定是错误地将 edit
放在那里而不是 reword
。或者 Git 可能由于在输出中发现的错误而进入了此模式(这也是在冲突中进入的):
This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout. could not detach HEAD
您应该在继续之前解决此错误。 Git 告诉你该怎么做。
edit
模式允许像 reword
模式一样修改提交消息,但也可以修改文件内容。因此 Git 让您处于可以提交更改然后使用 git rebase --continue
.
继续变基的状态
在 edit
模式下编辑提交消息(如 reword
)
当您只想编辑提交消息并继续变基时,运行
git commit --amend
这会打开编辑器让您编辑提交消息。完成后,运行
git rebase --continue
留下未完成的 rebase
As soon as I save the file, Git, instead of showing me the next rebase window to pick a new name for that commit as usual, it puts itself and informs me of a detached HEAD state with that commit, that is also shown upon git status
command from then on, until I type git checkout master
.
这不是留下未完成的rebase的正确方法,你应该使用
git rebase --abort
相反。
我在 git rebase -i
上遇到了同样的问题,输出完全相同,但完全没有说明 git 的原因。
通过反复试验,我最终发现我的 post-checkout hook (repodir/.git/hooks/post-checkout) 以非零值退出状态。一旦我在它的末尾添加了一个 exit 0
,rebase 就成功了,没有让 repo 处于分离的 HEAD 状态。
我正在尝试在某个项目上改写倒数第二个提交以修复 运行 git rebase -i HEAD~3
的拼写错误,(使用 "nano" 编辑器)然后更改默认值 pick
选项提交到 r
或 reword
(在初始变基文件 window 上),并且不修改任何其他内容。如果有用的话,我在 master
分支上做。
一旦我保存了文件,Git,它并没有像往常一样向我显示下一个变基 window 来为该提交选择一个新名称,而是它自己告诉我一个与该提交分离的 HEAD 状态,从那时起也显示在 git status
命令上,直到我键入 git checkout master
.
无论我尝试多少次,同样的事情都会发生。
附加说明:我之前通过 运行 单个命令将使用的编辑器更改为 "nano":git config --global core.editor nano
编辑:根据要求,这是 Git 在我保存 TODO 列表时给我的消息:
adrian$ git rebase -i HEAD~1
Note: checking out 'da91bbcedc78cb2ebcaa9dc51f38c8d0a550195d'.
You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b
HEAD is now at da91bbc... Test message
This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout. could not detach HEAD
此时运行git rebase --continue
后输出:
No rebase in progress?
当您将 edit
放入交互式变基的待办事项文件中时,分离的 HEAD 消息正常出现。您一定是错误地将 edit
放在那里而不是 reword
。或者 Git 可能由于在输出中发现的错误而进入了此模式(这也是在冲突中进入的):
This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout. could not detach HEAD
您应该在继续之前解决此错误。 Git 告诉你该怎么做。
edit
模式允许像 reword
模式一样修改提交消息,但也可以修改文件内容。因此 Git 让您处于可以提交更改然后使用 git rebase --continue
.
在 edit
模式下编辑提交消息(如 reword
)
当您只想编辑提交消息并继续变基时,运行
git commit --amend
这会打开编辑器让您编辑提交消息。完成后,运行
git rebase --continue
留下未完成的 rebase
As soon as I save the file, Git, instead of showing me the next rebase window to pick a new name for that commit as usual, it puts itself and informs me of a detached HEAD state with that commit, that is also shown upon
git status
command from then on, until I typegit checkout master
.
这不是留下未完成的rebase的正确方法,你应该使用
git rebase --abort
相反。
我在 git rebase -i
上遇到了同样的问题,输出完全相同,但完全没有说明 git 的原因。
通过反复试验,我最终发现我的 post-checkout hook (repodir/.git/hooks/post-checkout) 以非零值退出状态。一旦我在它的末尾添加了一个 exit 0
,rebase 就成功了,没有让 repo 处于分离的 HEAD 状态。