我做了一件蠢事,结果引起了冲突。我解决了冲突,现在一切都好了(我也使用了mergetool)。

当我用git commit file.php -m "message"提交解析文件时,我得到了错误:

fatal: cannot do a partial commit during a merge.

我以前遇到过同样的问题,在commit中使用-a工作得很好。我认为这不是完美的方式,因为我不想提交所有的更改。我想用单独的注释单独提交文件。我该怎么做呢?为什么git不允许用户在合并后单独提交文件?对于这个问题,我找不到满意的答案。


当前回答

对于我自己来说,当我试图在解析所有文件之前提交合并时,在SourceTree中发生了这种情况。然后我将最后一个文件标记为已解决,但在尝试提交时它仍然给了我这个错误。我关闭了SourceTree并重新打开它,然后它就正常了。

其他回答

git commit -am 'Conflicts resolved'

这对我很管用。你也可以试试这个。

你可能在某些事情上有冲突,但你还没有准备好。git不会让你独立提交东西(因为这都是合并的一部分,我猜),所以你需要git添加那个文件,然后git commit -m "合并冲突解决"。git commit的-i标志为你添加。

有时在合并过程中,如果出现冲突,并且存在需要手动解决的增量。在这种情况下,修复手动解决文件提到。

如果你提出,

git status Lib/MyFile.php

您将看到如下输出

On branch warehouse
Your branch and 'origin/warehouse' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:

    modified:   Lib/MyFile.php

因为您已经执行了提交,所以您只需要发布

git commit

你的承诺将会毫无问题地完成。

你的合并在动作中间停止了。 你应该添加你的文件,然后'git commit':

git 添加file_1.php file_2.php file_3.php git 提交

干杯

看起来您错过了提交命令的-m