[Git:commit错误] Fatal: cannot do a partial commit during a merge

注:本文出自博主 Chloneda个人博客 | 博客园 | Github | Gitee | 知乎

问题场景

今天进行Spring Boot版本升级,解决冲突后进行代码文件提交时出现这个错误。

上午11:56 Commit failed with error
        0 files committed, 5 files failed to commit: 升级Spring Boot版本,解决代码冲突。
        cannot do a partial commit during a merge.

其中最后一行的意思是不能部分提交代码。这是因为git提交代码时有部分代码没有做好提交的准备。

解决方法

  1. 全部提交。
git commit -a
  1. 部分提交,可以通过添加 -i 参数。
git commit file -i -m "merge"

然后解决一下冲突就可以提交了!

原文地址:https://www.cnblogs.com/chloneda/p/git-commit-apart.html