有什么方法可以比较Git中的两个文件而无需更改其格式? [英] Is there any way to compare two files in Git without their formatting changes?

查看:52
本文介绍了有什么方法可以比较Git中的两个文件而无需更改其格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经提交了一些具有某种格式的代码,但是原点具有其他格式.审稿人要我还原所有更改,我正在Git中寻找某种UI工具或某种方式来删除格式并提供实际结果.

I have committed some code with some format but the origin has some other format. The reviewer is asking me to revert all my changes and I am searching for some UI tool or some way in Git to remove formatting and give the actual result.

推荐答案

我认为您可能会看看git diff,尤其是以下两个选项:

I think you might have a look at git diff, in particular the two following options:

-b, --ignore-space-change
   Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.

-w, --ignore-all-space
   Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.

因此运行git diff --ignore-all-space

但是,如果您通过格式化定义的不只是空格,我想您必须手动完成

However, if what you define by formatting is not just whitespace, I guess you have to do it by hand

这篇关于有什么方法可以比较Git中的两个文件而无需更改其格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆