skip to main content
Avatar of Nicklas Jarnesjö
Nicklas Jarnesjö

Get case sensitive renaming in git on macOS working

code

More then once I have changed name on a file and then deployed it and then discovered something broke the deploy. And in some of this cases was because git didn't pick up my renaming of some file but the references got changed.

And this because macOS isn't case sensitive but Linux are and here is where the mismatch is happening.

So my go to solution for this has been either copy the source of the file deleted it and made a commit and then added it back with correct name. Or change it some stupid name commit and the change again to my preferred name and commit again 🙄

So instead of doing (which isn't working)

mv defaultLayout.tsx DefaultLayout.tsx

I found out you can do it with git mv

git mv defaultLayout.tsx DefaultLayout.tsx

and git will pick up and everything works as expected 👌

Discuss this post on Twitter