如何在Git中执行不区分大小写的diff [英] How to perform case insensitive diff in Git

查看:351
本文介绍了如何在Git中执行不区分大小写的diff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git diff 不支持不区分大小写的文件比较。谷歌显示只有少数人要求使用该功能,并且仅与其他一些 git diff 开关一起使用,例如 -G 或与 - color-words



我不关心其他开关,只要 git diff 可以显示不区分大小写的差异。



因为我没有看到任何具体问题因为我在研究这个问题一个小时后发现了一个解决方案,所以我添加了这个问题和答案。 解决方案

解决方案是使用 git difftool 。使用下面的配置命令,我可以为Git添加一个名为 idiff 的自定义 diff 工具:



git config --global difftool.idiff.cmd'diff -i $ LOCAL $ REMOTE'



使用此自定义,我可以看到不区分大小写的比较,如下所示:

git difftool --tool idiff <其他比较选项> < Git references or files>



例如

git difftool -t idiff HEAD〜1 - my_schema.sql



由于 git difftool 提示符(对于是/否),可以使用 -y 切换为 difftool 或添加此配置选项以避免提示:



git config --global difftool.prompt 0


git diff does not support a case-insensitive comparison of files. Google shows a very few people asking for that feature, and that too only in combination with some other git diff switch, like with -G or with --color-words.

I don't care for other switches, as long as git diff can show me the case-insensitive diff.

Since I didn't see any specific question towards that, and since I found a solution after an hour researching this problem, I am adding this question and the answer.

解决方案

The solution is to use git difftool. With the following config command, I can add a custom diff tool called idiff for Git to use:

git config --global difftool.idiff.cmd 'diff -i $LOCAL $REMOTE'

With this customization, I can see the case-insensitive comparison like so:

git difftool --tool idiff <other diff options> <Git references or files>

Eg.

git difftool -t idiff HEAD~1 -- my_schema.sql

Since git difftool prompts (for yes/no) every time before invoking the the tool, either use -y switch for difftool or add this config option to avoid the prompt:

git config --global difftool.prompt 0

这篇关于如何在Git中执行不区分大小写的diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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