In a Git repository, how to properly rename a directory?

qazwsx picture qazwsx · Jun 25, 2012 · Viewed 372.7k times · Source

I think it should work to copy the directory to be renamed to a new directory with desired name, and delete the old directory, and git add, git commit and push everything. But is this the best way?

Answer

CB Bailey picture CB Bailey · Jun 25, 2012

Basic rename (or move):

git mv <old name> <new name>

Case sensitive rename—eg. from casesensitive to CaseSensitive—you must use a two step:

git mv casesensitive tmp
git mv tmp CaseSensitive

(More about case sensitivity in Git…)

…followed by commit and push would be the simplest way to rename a directory in a git repo.