Search code examples
gitsmartgit

How to make git ignore changes in case within files?


I have seen this question on how to make git ignore changes in case by using one of the following two commands:

git config core.ignorecase true
git config --global core.ignorecase true

The first one being for the local repository only, the latter to change it globally.

I was wondering if there is a way to make git ignore such changes in case within files, e.g. ignoring if changed to IF.


Solution

  • No, there isn't. The flags you're talking about only affect the file names and not their contents. However, when you run git diff you can enable text converters that normalise the content (say, to all lowercase) and then run the resulting diff on there. The Git content will still store the mixed case files but you can view it in different ways.

    If you want to do the processing before the commit occurs you can use a git commit hook to do the transformation.