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

我从我的分支对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

当前回答

当我有未分级文件时,我得到了这个警告。确保没有任何非暂存文件。如果不希望更改非暂存文件,则使用

git rm <filename>  

其他回答

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

我只是偶然发现了这个问题。我就不改了,跳过 因为git状态清楚地显示了阶段性的修改,这是我想保留的。虽然我有一些意外的额外文件。我决定

git checkout .

要删除未分段的修改,则git rebase—continue succeeded。

在修复冲突时,您删除了应用于您所基于的分支的补丁中的所有代码。如果你确定你已经添加了所有的更改:使用git rebase—skip继续。

有疑问时

为了确保你不会失去任何工作:

取消你的基地重组,蠢货,取消 然后创建一个新的分支git checkout -b my-rebasebranch git Rebase origin/main(或其他)

更多的细节:

通常,当在重基期间修复冲突时,您将编辑冲突文件,保留当前应用于重基分支的补丁中的部分或全部代码。在修复补丁后做

git add your/conflicted/file
git status

您将看到一行(通常是绿色)显示修改后的文件

修改:你/冲突/文件

Git rebase -continue在这种情况下可以正常工作。

然而,有时在解决冲突时,您会删除新补丁中的所有内容,只保留重新基于的分支的代码。现在,当您添加文件时,它将与您试图重新基于的文件完全相同。Git状态不会显示绿色线显示修改后的文件。现在,如果你知道

git rebase --continue

Git会抱怨

没有变化-你忘记使用'git add'了吗?

如果您确定已经添加了所有更改,那么git在这种情况下实际希望您做的就是使用

git rebase --skip

跳过补丁。以前我从来没有这样做过,因为我总是不确定如果我这样做了,实际上会跳过什么,对我来说,“跳过这个补丁”的真正含义并不明显。但如果你没有绿线

修改:你/冲突/文件

在编辑冲突文件、添加它并执行git status之后,您可以相当肯定地删除了整个补丁,并且可以使用

git rebase --skip

继续。

最初的帖子说,这种方法有时有效: git添加-A Git rebase—继续 #神奇地起作用了?

... 但不要依赖于此(并确保不要在存储库文件夹中添加剩余文件)

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.

一旦你修正了你的改变你可能会忘记运行'git add -A'

git add -A
git rebase --continue