Git Product home page Git Product logo

git-detect-case-change's Introduction

git-detect-case-change

Script to stage file-path 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! โค๏ธ

Usage

After renaming files, run the script with npx in your Git repository:

npx git-detect-case-change

If there were any case-changes, it will detect and stage them for you.

Dry run

Run with --dry to see what files would be renamed before staging them:

npx git-detect-case-change --dry

Scoping files

Pass in specific paths after -- to scope the search to:

npx git-detect-case-change -- <scope to directory path>

Why?

File-systems on macOS & Windows are case-insensitive by default, which means paths /a.txt and /A.txt cannot exist at the same time. Because of this default, Git is also case-insensitive by default, preventing it from detecting case changes in file names.

The recommended solution from this StackOverflow discussion is to rename the files individually with git mv:

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

However, this may not be practical if the case-changes were made without Git (eg. automated by another program) and there's a lot to rename.

This script automates case-change detection for Git.

How does it work?

  1. Get the case-sensitive file paths from the current Git project:

    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 case, register the change with Git:

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

git-detect-case-change's People

Contributors

privatenumber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jeniex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.