Search code examples
windowsgitrename

Git: rename directory (case-only) on Windows


I want to rename a directory versioned by Git on a Windows system (change the case of the directory name):

$ git mv docs DOCS
Rename from 'docs' to 'DOCS/docs' failed. Should I try again? (y/n) n
fatal: renaming 'docs' failed: Permission denied

I've also tried with the force-option - but with the same result:

$ git mv --force docs DOCS
Rename from 'docs' to 'DOCS/docs' failed. Should I try again? (y/n) n
fatal: renaming 'docs' failed: Permission denied

For some reason Git fails because it thinks DOCS already is an existing directory and the directory should be moved inside it. I know that I can rename & commit using a temporary directory name and then rename & amend-commit to the final name, but isn't there a way to tell Git that I don't want to move inside any other directory?


Solution

  • You can try to do it in 2 step.

    $ git mv docs DOCS2
    $ git mv DOCS2 DOCS
    

    it will work