inline Changing the case of a git directory on a case-insensitive file system

Originally published on May 1st, 2020 (Last updated on May 1st, 2020)

If you com­mit the file main.c in the direc­to­ry Test to git on a case sen­si­tive file sys­tem (such as ext4), git will write the path as Test/main.c.

When check­ing that repos­i­to­ry out on a sys­tem with a case insen­si­tive file sys­tem (like NTFS) the explor­er might tell you that your file is in test/main.c, but doing some­thing like git log -- test/main.c will not yield any results. Where­as git log -- Test/main.c will work fine.

To change the case of the direc­to­ry con­tain­ing the main.c file on such a case insen­si­tive file sys­tem, you might run git mv Test test, but it will fail. The workaround is to first rename the direc­to­ry to some­thing else and then again to the name you want:

git mv Test asd git mv asd test

This should result in changes for all files in the direc­to­ry. Com­mit­ting these will fix the problem.


No com­ment sec­tion here 😄

You can reach me over at @knuth_dev or send me an Email.