Git might ignore file renames that differ only in character case

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the git category.

Last Updated: 2024-11-21

Git, by default, ignores file renames that only change the name to use different character cases.

I had a file appointmentsApp.js and renamed it to AppointmentsApp.js. This worked locally but git didn't pick up any changes (i.e. nothing showed up after git status.)

I shrugged and deployed to Heroku. Then got an error: could not find module AppointmentsApp

It turned out that git has an option ignorecase that was active in my repo.

What's more, my macOS filesystem is "case insensitive but case preserving". That means the file system will consider foo and FoO to be the same, but will remember what letters were capitalized.

I fixed by running $ git mv appointmentsApp.js AppointmentsApp.js

I then disabled this git configuration option globally on my machine:

git config --global core.ignorecase false