The case of the OS X filesystem HFS+ and git

Yesterday I stumbled across a problem when renaming files in a git repository by just changing the case of some characters. I wonder why I did not come across that earlier, maybe I did care about naming conventions for Java classes enough.

We renamed a Java class in IntelliJ from ProjectDao.java to ProjectDAO.java. After committing and pushing the changes, a colleague had a problem, compiling the code. The reason was, that the file name in his repository still was ProjectDao.java, but it contained a class called ProjectDAO - which does not compile in Java.

So I did a little research on why this happened. First I found posts about a git setting called core.ignorecase which (as the name says) tells git to ignore the case. I checked my configuration and found that the setting was not configured so the default value false used.

Another post on stackoverflow hinted that renaming the files via git mv with the option -f would track the change. I tried the command

git mv -f ProjectDao.java ProjectDAO.java

and that did the trick, my git repository recognized the change as a renamed file:

After trying again in IntelliJ IDEA, I saw that the renaming operation did not work correct there, so I filled a bug in their issues tracker.

I always thought, after switching to Mac OS, I would not have to deal with those weird case problems, we always had when working in mixed teams with Windows an Linux and other source code management systems like Subversion or CVS. So I was shocked when I became aware of this issue.

After digging even deeper, I found this blog post and this post on apple stackexchange telling me that HFS+, the default file system on OS X, is not case sensitive but only case preserving. For me it was always clear that the underlying Unix of OS X uses a filesystem that is case sensitive - but no. I checked my disks with diskutil info and had to see the following:

Which means that my disk was formatted case insensitive. When creating a partition in the diskutil you can select case sensitive , but the installer did not do that per default. There are ways to change the system to case sensitive with a third party tool like iPartition but I hesitate to make such a big change.

For now I guess I have to wait for IntelliJ to fix that issue and in the meanwhile do the renaming via the git command in the terminal.

btw: I checked with Eclipse and egit to - they already handle this correct!