gpt4 book ai didi

git - 如何在 Git 中执行不区分大小写的差异

转载 作者:IT王子 更新时间:2023-10-29 01:15:33 24 4
gpt4 key购买 nike

git diff 不支持不区分大小写的文件比较。谷歌显示很少有人要求该功能,而且也只能与其他一些 git diff 开关结合使用,例如 -G--color -单词

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

由于我没有看到任何具体问题,而且我在研究这个问题一个小时后找到了解决方案,所以我添加了这个问题和答案。

最佳答案

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

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

通过这种定制,我可以像这样看到不区分大小写的比较:

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

例如。

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

git difftool每次调用该工具之前都会提示(是/否),或者使用 -y切换为 difftool或添加此配置选项以避免提示:

git config --global difftool.prompt 0

更新(2021 年 11 月 26 日):这是我使用的综合配置,它允许我使用 git idiff命令的行为几乎与 git diff 相同行为。

git config --global difftool.idiff.cmd 'diff --unified=3 --color=always --ignore-case $LOCAL $REMOTE | less --raw-control-chars'
git config --global difftool.prompt 0
git config --global alias.idiff 'difftool --tool idiff'

关于git - 如何在 Git 中执行不区分大小写的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17380029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com