Git FAQ

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

First, make sure that the answer to your question is not somewhere in the official documentation:
http://git-scm.com/

How to rename a file with Git

Use:

git mv old-name new-name

Be careful: To preserve history, you have to carefully do a commit that only renames. Do not commit something that changes the file name as well as changes its content. 1

If you do git log -M -p you will see the message of the rename, like in the following example:

diff --git a/old-file.php b/new-file.php
similarity index 100%
rename from old-file.php
rename to new-file.php