如果开发人员使用不同的代码美化器,您如何处理 git 合并冲突?

How do you handle git merge conflicts in case developers are using different code beautifier?

现在的情况是,我遇到了 git 冲突,尽管代码相似,但每个开发人员的代码格式不同。

这种确切情况是开发代码 linter 的原因之一。

lint, or a linter, is a tool that analyzes source code to flag programming errors, bugs, stylistic errors, and suspicious constructs. The term originates from a Unix utility that examined C language source code

您可以使用 linter 在您和您的项目合作伙伴之间强制执行代码约定。 Linters 可以强制执行缩进、运算符周围的间距等内容。

每个人都使用相同的格式,应该尽量减少冲突,当冲突确实发生时,linter 通常会告诉您如何修复样式。