git-detect-case-change

1.0.0 • Public • Published

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-change

How does it work?

  1. 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 HEAD
  2. Check each file path with fs.promises.exists to find a case-insensitive match.

  3. If the path exists with a different casing, tell git:

    git mv <old-path> <new-path>

Package Sidebar

Install

npm i git-detect-case-change

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

66.3 kB

Total Files

5

Last publish

Collaborators

  • hirokiosame