Git:merge后如何检查是否还存在冲突没有处理

概要

Git:merge 后如何检查是否还存在冲突没有处理

博客

原帖收藏于IT老兵博客

前言

在工作中,遇到一个问题,在git merge后,发生冲突,而当冲突较多的时候,逐个检查冲突,有的时候会遗漏一些文件,导致带有冲突标记的文件上传到了 Git 服务器上,如何解决这个问题呢?

正文

使用以下命令可以快速检查是否还存在有带有冲突标记的文件。
git diff --check

说明:

–check
Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with –exit-code.

上文摘录自手册官网,这个命令会检查 conflict markers(冲突标记)和whitespace errors(空格错误)。

总结

Git 是一个相对比较复杂的工具,我发现,复杂往往源自于过于灵活,它的功能非常强大,掌握好了,就可以事半功倍,但是,把它掌握好,是需要花费一些时间成本的。感觉学习 Git,可能需要既需要正面地一篇篇去阅读手册,也需要这样涓涓细流地不断总结各种场景下的用法,也许,这本身就是学习的一种方法。

参考

https://git-scm.com/docs/git-diff
https://ardalis.com/detect-git-conflict-markers