Solving that pesky file rename in git with APFS Volumes
I’ve been using this setup for over 2 years now and it saved me from a large number of small to medium headaches that used to haunt me every so often. Because of this, I think it’s worth talking about in a blog post.
So what am I talking about? #
Ever had to commit a file only to realise that you got the capitalisation wrong? I’ve certainly been in that situation.
Well you’d think that you could just go back, edit the filename,
git commit --commit and you’re good, right? Wrong.
Well… Wrong for most users at least, because most of them will notice that the naming change wasn’t picked up by git.
The reason why? It’s probably because you’re using a case-insensitive file system. It used to be the default option for HFS+, and it still is the default for APFS. Some applications rely on this to be the case, like the Adobe suite, so you don’t want to change case-sensitivity for your whole system drive.
Volumes to the rescue! #
APFS redefines partitions with the introduction of volumes. Normal partitions and APFS volumes differ in many ways, but the two that we care about in this case are:
- Space sharing - volumes don’t have predetermined sizes and will be able to “grow” until there’s no space left in the container.
- Independent configuration - different volumes can have different variants of APFS setup. In our case we can have a case-insensitive volume and a case-sensitive one.
So, in my case I created a new volume APFS called Projects with case-sensitive filenames and put all of my code and repositories in it.
Et Voilà! All filename changes are now getting picked up by