How Do I Commit Case-Sensitive Only Filename Changes in Git?

Better Stack Team
Updated on June 24, 2024

To commit only case-sensitive filename changes in Git, you need to perform the following steps:

  1. Rename the File with a Temporary Name: Start by renaming the file to a temporary name, ensuring it differs only in case. For example, if you have a file named MyFile.txt, you can rename it to tempfile.txt.

    git mv MyFile.txt tempfile.txt
  2. Commit the Renamed File:

    git commit -m "Rename MyFile.txt to tempfile.txt"
  3. Rename the File Back to Its Original Name: After committing the rename, rename the file back to its original name with the correct case.

    git mv tempfile.txt MyFile.txt
  4. Commit the Final Change:

    git commit -m "Rename tempfile.txt back to MyFile.txt with correct case"


  • Git's default behavior on case-insensitive filesystems (like on Windows and macOS) may not recognize changes in file names that only differ in case. By following these steps, you explicitly tell Git about the change by renaming the file.
  • It's essential to commit the file rename in two separate steps to ensure that Git tracks the case-sensitive filename change correctly.
  • Be cautious when performing file renames, especially if the file is actively being used or referenced by other parts of the codebase.
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github