我正面临一个我不知道如何解决的问题。

我从我的分支对master做了一个rebase:

git rebase master

并得到以下错误

 First, rewinding head to replay your work on top of it...
 Applying: checkstyled.
 Using index info to reconstruct a base tree...
 Falling back to patching base and 3-way merge...
 Auto-merging AssetsLoader.java
 CONFLICT (content): Merge conflict in AssetsLoader.java
 Failed to merge in the changes.
 Patch failed at 0001 checkstyled.

所以我去我最喜欢的编辑器,修复了1行冲突,保存文件,并做了一个git状态,得到以下输出:

 # Not currently on any branch.
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #  modified:   PassengerContactHandler.java
 #
 # Unmerged paths:
 #   (use "git reset HEAD <file>..." to unstage)
 #   (use "git add/rm <file>..." as appropriate to mark resolution)
 #
 #  both modified:      AssetsLoader.java
 #

我做了一个git添加AssetsLoader.java和一个git状态,并得到如下:

 # Not currently on any branch.
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #  modified:   AssetsLoader.java
 #  modified:   PassengerContactHandler.java
 #

当我git rebase -continue时,我得到:

git rebase --continue
You must edit all merge conflicts and then
mark them as resolved using git add

我知道我可以跳过补丁并继续重新建立基础,但我不确定passenger - contacthandler .java中的更改是否会重新建立到我的分支中。

所以我不确定,我该怎么做?

编辑:是否冲突解决后的文件与原始版本完全相同?

非常感谢, 卢卡斯

编辑,我又遇到了这样的事:

又发生在我身上了,

(307ac0d...)|REBASE)$ git status
# Not currently on any branch.
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   assets/world/level1/Level-1.xml
#   modified:   George.java
#   modified:   DefaultPassenger.java
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   mb-art/originalAssets/27dec/

((307ac0d…)|REBASE)$ git REBASE—继续

You must edit all merge conflicts and then
mark them as resolved using git add

去 --版本

git version 1.7.1

当前回答

在修复冲突之后,确保将更改的文件添加到暂存文件中。这为我解决了问题。

其他回答

您在assetloader .java中错过了合并冲突。打开它,寻找冲突标记(“>>>>”,“====”,“<<<<<”),然后再次进行git添加。如果你很难找到它,就做一个“git diff - staging”。

试着在你的命令行中运行:

$ git mergetool

应该会弹出一个交互式编辑器,允许您解决冲突。这比手动操作要简单,而且git在合并时也能识别。也将避免当您尝试手动操作时,意外发生的不完全合并的情况。

我刚刚遇到了这个问题,虽然我认为可能有一些原因,但这是我的……

我有一个git预提交钩子,它在某些条件下拒绝提交。这在手动提交时很好,因为它将显示钩子的输出,我可以使用commit——no-verify修复它或选择忽略它。

问题似乎是,当重基时,rebase——continue也会调用钩子(为了提交最新一轮的更改)。但是rebase不会显示钩子输出,它只会看到它失败了,然后抛出一个不太具体的错误,说“你必须编辑所有合并冲突,然后将它们标记为使用git add解决”

要解决这个问题,请阶段性地执行所有更改,而不是执行“git rebase—continue”,而是尝试执行“git commit”。如果你也遇到了同样的问题,你应该看到它失败的原因。

有趣的是,虽然git rebase不显示来自git钩子的输出,但它确实接受——no-verify来绕过钩子。

似乎是Git 1.7的一个bug

这里有一篇关于如何解决这个问题的好文章。(链接在2022年似乎不再有效)

如果你做一个

git diff

在解决了你们的矛盾之后

git rebase --continue

应该工作。

If you are using magit (a popular emacs frontend to git), this error message can be shown due to an obscure bug in magit. I'm not exactly sure what triggers this bug, but for me it was that only the line endings were changed for a file, and so magit didn't display the file as a conflict. So I thought there were no conflicts remaining, but there were. Running git status at the command line allowed me to see the conflicting file, and I could then run git add filename and then git rebase --continue.