{"id":16347471,"url":"https://github.com/privatenumber/git-detect-case-change","last_synced_at":"2025-03-21T00:30:21.173Z","repository":{"id":44707954,"uuid":"430043127","full_name":"privatenumber/git-detect-case-change","owner":"privatenumber","description":"🤖 Script to detect file name case changes in a Git repository","archived":false,"fork":false,"pushed_at":"2023-01-28T06:04:48.000Z","size":359,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-03-17T18:53:50.643Z","etag":null,"topics":["case","case-sensitive","detection","git","rename"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/privatenumber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-20T07:55:46.000Z","updated_at":"2025-02-13T16:00:24.000Z","dependencies_parsed_at":"2023-02-15T14:45:43.609Z","dependency_job_id":null,"html_url":"https://github.com/privatenumber/git-detect-case-change","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fgit-detect-case-change","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fgit-detect-case-change/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fgit-detect-case-change/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fgit-detect-case-change/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/git-detect-case-change/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717070,"owners_count":20498279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["case","case-sensitive","detection","git","rename"],"created_at":"2024-10-11T00:42:45.573Z","updated_at":"2025-03-21T00:30:20.629Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-detect-case-change\n\nScript to stage file-path case changes in a Git repository.\n\n\u003csub\u003eSupport this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️\u003c/sub\u003e\n\n## Usage\n\nAfter renaming files, run the script with [npx](https://nodejs.dev/learn/the-npx-nodejs-package-runner) in your Git repository:\n```sh\nnpx git-detect-case-change\n```\n\nIf there were any case-changes, it will detect and stage them for you.\n\n#### Dry run\nRun with `--dry` to see what files would be renamed before staging them:\n```sh\nnpx git-detect-case-change --dry\n```\n\n#### Scoping files\n\nPass in specific paths after `--` to scope the search to:\n```sh\nnpx git-detect-case-change -- \u003cscope to directory path\u003e\n```\n\n## Why?\nFile-systems on macOS \u0026 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.\n\nThe recommended solution \nfrom this [StackOverflow discussion](https://stackoverflow.com/questions/17683458/how-do-i-commit-case-sensitive-only-filename-changes-in-git) is to rename the files individually with `git mv`:\n```sh\ngit mv \u003cold-path\u003e \u003cnew-path\u003e\n```\n\nHowever, 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.\n\nThis script automates case-change detection for Git.\n\n## How does it work?\n1. Get the case-sensitive file paths from the current Git project:\n    ```sh\n    git ls-tree --name-only -r HEAD\n    ```\n\n2. Check each file path with [`fs.promises.exists`](https://github.com/privatenumber/fs.promises.exists) to find a case-insensitive match.\n\n3. If the path exists with a different case, register the change with Git:\n    ```sh\n    git mv \u003cold-path\u003e \u003cnew-path\u003e\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fgit-detect-case-change","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fgit-detect-case-change","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fgit-detect-case-change/lists"}