git-detect-case-change v1.0.0
git-detect-case-change
Script to detect file name case changes in a Git repository.
Support this project by ⭐️ starring and sharing it. Follow me to see what other cool projects I'm working on! ❤️
Why?
macOS and Windows file-systems are case-insensitive by default, preventing Git from recognizing file name case changes when renamed without Git (eg. StackOverflow discussion).
The recommended solution is renaming the files through Git:
git mv <old-path> <new-path>However, this is not always plausible to do if the case-changes have already been completed without Git (eg. autonamted by separate process) and there's a lot to rename.
This script automates case change detection for Git.
Usage
Simply run the script in your Git repository. Run with --dry to see what files would be renamed before staging them.
Use npx to run:
npx git-detect-case-changeHow does it work?
Get the case-sensitive file names from Git in the current project.
This is done with the following command:
git ls-tree --name-only -r HEADCheck each file path with
fs.promises.existsto find a case-insensitive match.If the path exists with a different casing, tell git:
git mv <old-path> <new-path>
4 years ago