Rename files and folders with GIT

Here are the steps for renaming a old folder folder_old with new folder folder_new
Step 1: User git mv to move the folder

git mv folder_old folder_new

Step 2: Add the changes to index

git add -uĀ folder_new

Step 3: Finally commit the changes to git server

git commit -m "renamed folder_old to folder_new"

Note: For step 1 if folder_new already exists in repository then -f (force) option will overwrite new folder

git mv -f folder_old folder_new

Leave a Reply