Search code examples
windowsgitfilenames

Change case of a file on Windows?


There are a couple of files in our git-controlled codebase that I'd like to rename. Specifically, I just want to change the case of the file, so that sourceCode.java becomes SourceCode.java, for example. The catch: I'm on a Windows box, and the filesystem thinks those are the same file name.

How can I get Windows and Git to recognize that change and check it in? The change of the file name should not be ignored, but committed to git.


Solution

  • To rename the file you can use the standard git mv command. Since Windows treats files with only changes in case as identical, you have to pass the -f option to force a rename:

    git mv -f name.java Name.java
    

    If instead you want to ignore case changes, have a look at the question How to make git ignore changes in case?.