Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 928
Thomas S. Avatar asked Apr 22 '16 17:04

Thomas S.


People also ask

How do I rename a directory in git?

To rename any file or folder, use git mv command which takes two arguments. The first argument is the source and the second is the destination. We can easily rename any file using the git command and the new name will be assigned to that file. We can rename the file using GitHub or the command line.

Can I rename my repository folder?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under the Repository Name heading, type the new name of your repository. Click Rename.


1 Answers

You can try to do it in 2 step.

$ git mv docs DOCS2 $ git mv DOCS2 DOCS 

it will work

like image 101
Pierre-Luc Dupont Avatar answered Oct 24 '22 01:10

Pierre-Luc Dupont