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


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?


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.

How do I see the commit differences between branches in git?

Rollback to an old Git commit in a public repo