【问题标题】:Error when reordering commits with git rebase -i使用 git rebase -i 重新排序提交时出错
【发布时间】:2013-08-13 17:34:04
【问题描述】:

我正在尝试重新排序 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

这将我带入 nano:

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

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

repo 中唯一的文件似乎有冲突:

$ 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

这让我发疯了,感谢任何帮助。

【问题讨论】:

  • 您确定将文件重新添加到索引中吗?如果您不这样做,rebase 仍会认为文件存在冲突
  • 你必须在 git -rebase -i 之前添加文件?
  • 不,你不应该在变基之前添加文件,git rebase --continue 应该在你解决冲突后处理所有事情。

标签: git rebase git-rebase


【解决方案1】:

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

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

【讨论】:

  • 也许这取决于 git 的修订版本,但有时 git 会发出一条看起来很吓人的消息,听起来好像你必须先采取行动才能继续,但它并没有告诉你什么的本质你所要做的。我只是有一种情况,我认为我的分支上的两个提交已经在 master 上,形式是在 master 上的一次提交。所以我开始使用 rebase -i master 并将两个提交移到待办事项的开头并修复了第二个。我收到了可怕的“无法申请”消息,没有建议的修复,没有状态。我确实 rebase --continue 并且它起作用了。
  • “工作”是指我的变基消除了两个提交。
猜你喜欢
  • 2015-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多