THE GITHTML FIELD GUIDE

Record a case-only filename rename in Git

When a filesystem treats differently capitalized names as the same path, a case-only rename may not be recorded as expected. Use a unique temporary intermediate name with git mv, then move to the intended spelling and inspect the staged change. Do not change core.ignoreCase blindly or overwrite a colliding path to force the rename.

Confirm the exact tracked spelling

Git records path names, while the filesystem may compare them differently. A path that opens locally can fail on a case-sensitive build environment if imports or references use inconsistent capitalization. Inspect the name Git tracks rather than relying only on the file manager’s display. Also check that the desired destination does not already exist as a distinct tracked file.

A case-only change should be reviewed with references to the path, such as imports, scripts, or resource lookups. Renaming the file without updating those references can produce platform-specific failures. Keep unrelated content edits separate where possible so reviewers can see that the primary change is the spelling and its necessary callers.

Use a reviewed intermediate path

The example changes Parser.js to parser.js through a temporary name that must be unused. git mv updates the working path and index; it does not create a commit. Inspect the staged summary and patch afterward. If either move fails, inspect the current state before retrying rather than adding a force option.

  1. Choose an intermediate filename that cannot collide with existing source or generated files, and confirm it is gone from the final staged snapshot.
  2. Search references for the old capitalization and update only those that should follow the renamed path; similarly named symbols may be unrelated.
shell
git ls-files -- src/Parser.js src/parser.js
git status --short
git mv -- src/Parser.js src/parser-case-tmp.js
git mv -- src/parser-case-tmp.js src/parser.js
git diff --staged --summary
git diff --staged

Test the platform-sensitive behavior

Run the relevant build and tests, ideally including the project’s case-sensitive environment when available. A successful local import on a case-insensitive filesystem is weak evidence that every reference is correct. Inspect the final tracked path spelling and the commit’s file list before publishing.

Changing core.ignoreCase is not a substitute for understanding the underlying filesystem and can create confusing path behavior. Prefer the explicit rename sequence for this focused task. If two files differ only by case, coordinate a naming change that works across supported platforms rather than forcing both into a checkout that cannot represent them reliably. Document the portability reason in the commit message.

  1. After the intermediate rename, inspect the index for both the temporary name and the final name before committing. An interruption between the two moves can leave the temporary filename staged as the real outcome. Complete or deliberately reverse that specific transition instead of adding another intermediate path.
  2. Check resource references outside source imports, including manifest entries and documentation links. A local browser or filesystem may tolerate the old capitalization while a case-sensitive host rejects it. Verify the references that actually address the renamed file without mechanically changing similarly capitalized class names or visible labels.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All fixing git problems guides →

Read as MarkdownAll guides

Record a case-only filename rename in Git · gitHtml