Renaming files in git

This will contain the history:

git mv backup.html backup2.html
git mv index.html backup.html
git mv backup2.html index.html

Without history just rename the file to your liking on your file system.


You don't have to do anything special as you are not adding any new paths to be tracked.

You can just move the files around and use git add to update their contents.

mv index.html tmpname
mv backup.html index.html
mv tmpname backup.html

then:

git add index.html backup.html

or:

git add -u

or:

git commit -a -m "swap backup.html and index.html"

Tags:

Git