In a Git repository, if there’s a file named
readme.mdin previous commits and you want to change the filename toREADME.md, you may find that Git doesn’t recognize the change.
Git is case-insensitive by default. This article explains how to configure Git to be case-sensitive and fix filenames with the correct case.
Git Configuration#
Git ignores case by default. You can check the current configuration with this command:
git config core.ignorecase
# Output result: true
Change Git to be case-sensitive with the following command:
git config core.ignorecase false
Fixing Filenames#
git mv -f readme.md README.md
The
-fparameter means force rename.
Committing Changes#
After making the changes, you can commit them using the following commands:
git add README.md
git commit -m "docs: fix README.md filename case"
To check the status of your changes:
git status
# Output will show the rename operation
# renamed: readme.md -> README.md
