GIT.WTF

How to change a file name's capitalization, without changing its content?

Written by Mandeep Singh in Solving Mistories

Working with a team of various backgrounds is always tricky, everyone has its own way of doing things, their own standards, preferences, and styles. One of these preferences is the way we name our files. There are several ways people do it, for me, it's always kebab-case, but some of my colleagues like to name it in snake_case, and others do it in camelCase.

When writing a standard code, it's always essential to keep the conventions similar for a cleaner code and for that we have to change each other file names according to the one set as default for that particular project.

Doing so in your local file system is pretty straightforward, but git is case insensitive and does not recognize the changes made in the file name if you have not changed any letter. So as long as you are changing to an entirely different style that is kebab-case to camelCase you should be fine but if you are only changing the capitalization that you are fucked. To do this, you need to run the following command:

git mv --force myfile MyFile

Sign up below to receive updates, tips and more handy tutorials when git screws up. It’s good stuff & I don’t spam.

A PRODUCT BY KHURAFAT