Course Tonight

Course Tonight

Did You Know?

Docy turns out that context is a key part of learning.

Chapter 28: Renaming

Estimated reading: 1 minute 8 views
Parameter Details
-f or –force Force renaming or moving of a file even if the target exists

Section 28.1: Rename Folders

To rename a folder from oldName to newName:

git mv directoryToFolder/oldName directoryToFolder/newName

Followed by git commit and/or git push.

If the following error occurs:

fatal: renaming 'directoryToFolder/oldName' failed: Invalid argument

Use the following command:

git mv directoryToFolder/oldName temp && git mv temp directoryToFolder/newName

Section 28.2: Rename a local and the remote branch

The easiest way is to have the local branch checked out:

git checkout old_branch

Then rename the local branch, delete the old remote branch, and set the new renamed branch as upstream:

git branch -m new_branch
git push origin :old_branch
git push --set-upstream origin new_branch

Section 28.3: Renaming a local branch

You can rename a branch in the local repository using this command:

git branch -m old_name new_name

Leave a Comment

Share this Doc

Chapter 28: Renaming

Or copy link

CONTENTS