Git rebase 过程被分离的头卡住了

标签 git rebase

我正在尝试在某个项目上通过运行 git rebase -i HEAD~3 来改写倒数第二个提交以修复拼写错误,(使用“nano”编辑器)然后更改默认值 pick该 promise 的选项 rreword (在初始 rebase 文件窗口上),并且不修改任何其他内容。我在 master 上做分支,如果有用的话。

一旦我保存文件,Git 就不会像往常一样向我显示下一个 rebase 窗口来为该提交选择一个新名称,它会自行设置并通知我该提交的分离 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 放入交互式 rebase 的待办事项文件中时,分离的 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 继续 rebase 的状态。

edit 模式下编辑提交消息(如 reword)

当你只想编辑提交消息并继续 rebase 时,运行

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 过程被分离的头卡住了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48022325/

相关文章:

git - 如何从 git 历史记录中删除提交但保持图形完全相同,包括 merge ?

git - git 存储库可以处理的提交数量是否有上限?

git - 去安装: no install location for directory

reactjs - 如何将 firebase 与 React 功能组件同步?

GIT-重新设置-如何处理冲突

git - 将 RPGLE 从 GitHub 集成到 iSeries (IBM i)

git - 将最新提交拆分为多个分支

php - git 是否安装在 IBM/AS400 中

git - 如何仅使用管道命令查找 git 提交的日期?

Git没有执行接收后 Hook