How to perform case insensitive diff in Git

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'

Leave a Comment