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

时间:2013-08-13 17:34:05

标签: 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

我想交换132247f和0ddaef3。

$ git rebase -i 95f8007

这让我陷入纳米:

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

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

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

作为错误信息,它不是很有用......有人知道发生了什么事吗?

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

$ 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

如果我解决冲突,添加文件并运行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

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

1 个答案:

答案 0 :(得分:13)

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

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