Git is great! Even though it’s totally (hashtag) awesome sauce, you can encounter the occasional strangeness from time to time. My encounter deals with case sensitivity with both file names and also directory names.
I was given a directory that contained sub-directories for imagery we were using with a project. Without thinking I placed the folder into my project and went on my merry way. The problem though was that each of these sub-directories (4 in my case) had a capital letter and I was referencing them in my markup and stylesheet as a lowercase reference. So if the directory was named “Fake” I would place in my CSS
url(../fake/img.jpg). This works locally, but when I push to our dev server (Centos) the paths to assets break because our naming conventions don’t match (
fakedir doesn’t match
Fakedir). When u make a new commit Git still tracks the directory with a capital letter even though you’ve changed it to lowercase locally on your machine. Git does not “Git” it.
So what can we do to fix this? We’ll need to move and rename to an intermediate name and then name it back to the original name like the example below (we’re taking a directory named “Test” and renaming it to “test”):
If your gut is telling you this is a really long way to do things then I would tell you that your gut is right. What I had help discovering was that in OS X,
folder === Folder, so if you move, Git won’t see any difference. You have to explicitly tell Git about the move requiring the temporary name you see (
test2) in the bash commands above.
The quicker way is to manually remove all the directories from the local copy, commit and push this removal to your remote repo (i.e Github) then place these directories back into your local copy and rename the directories to lowercase. Not the best solution, but it’s more efficient than doing the commands listed above.
Whoever thought a case insensitive file system was a good idea probably should rethink things.