Leo's dev blog

How to safely rename a case sensitive file/directory in a git repo?

Published on
1 mins read

Simple file/directory renaming in git is not a problem. But what if you want to rename a case sensitive file/directory in your git repo? For example, you have a file named README.md and you want to rename it to Readme.md.

Keep in mind that renaming by IDE or file manager will not work because git will not recognize the change.

You can do it with the following command:

git mv README.md Readme.md

Then follow with the usual git workflow:

git add .
git commit -m "Rename README.md to Readme.md"

That's it! You have successfully renamed a case sensitive file/directory in a git repo.

Happy commiting!