Vanson's Eternal Blog

如何在git仓库中安全地重命名区分大小写的文件/目录?

Published on
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!