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

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

fatal: cannot do a partial commit during a merge.

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


当前回答

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

如果你提出,

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 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不会让你独立提交东西(因为这都是合并的一部分,我猜),所以你需要git添加那个文件,然后git commit -m "合并冲突解决"。git commit的-i标志为你添加。

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

简单地git commit -m“comment”应该在解决冲突后工作。

你可以在大多数情况下使用git commit -i,但以防它不起作用

你需要git commit -m "your_merge_message"。在合并冲突期间,您不能合并单个文件,因此需要合并

只运行冲突文件(git add your_file.txt) Git commit -m "your_merge_message"