使用git rebase -i重新排序提交时出错

cfi*_*her 9 git rebase git-rebase

我正在尝试重新排序2次提交,并且我一直收到错误而没有任何解释,所以我不知道我做错了什么.

这是回购:

$ git lol
* c0000ca (HEAD, master) added a title
* 132247f Turned colors to html
* 0ddaef3 Added last sentences
* 95f8007 initial commit
Run Code Online (Sandbox Code Playgroud)

我想交换132247f和0ddaef3.

$ git rebase -i 95f8007
Run Code Online (Sandbox Code Playgroud)

这让我陷入纳米:

pick 0ddaef3 Added last sentences
pick 132247f Turned colors to html
pick c0000ca added a title

# Rebase 95f8007..c0000ca onto 95f8007
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
Run Code Online (Sandbox Code Playgroud)

我交换两行,保存并退出.这是我收到的错误消息:

error: could not apply 132247f... Turned colors to html


When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply 132247f... Turned colors to html
Run Code Online (Sandbox Code Playgroud)

作为一个错误信息,它不是很有用....任何人都知道发生了什么?

回购中唯一的文件似乎存在冲突:

$ cat poem.md
<<<<<<< HEAD
Roses are red.
Violets are blue.

=======
Roses are #ff0000.
Violets are #0000ff.
All of my bases,
are belong to you.
>>>>>>> 132247f... Turned colors to html
Run Code Online (Sandbox Code Playgroud)

如果我解决冲突,添加文件并运行git rebase --continue,我得到另一个错误:

$ git rebase --continue
[detached HEAD 9aba127] Turned colors to html
 1 file changed, 4 insertions(+), 2 deletions(-)
error: could not apply 0ddaef3... Added last sentences

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply 0ddaef3... Added last sentences
Run Code Online (Sandbox Code Playgroud)

这让我发疯,任何帮助都表示赞赏.

qua*_*tka 13

看起来正在发生的事情是您在应用"将颜色变为html"时成功解决了第一次合并冲突,然后在应用下一次提交"添加最后一句"时遇到另一次合并冲突.

git status需要查看合并冲突是什么,解决它们然后继续git rebase --continue.