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
UPDATE (2021/11/26): Here's a consolidated configuration I use, that allows me to use git idiff command that behaves almost identical to how git diff behaves.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With