If you made an error while typing the branch name or decided to change the branch name after pushing it to the remote repository, there is a method to rename the branch both locally and remotely.
Table of Contents
1. Rename the Local Branch
# Switch to the branch git checkout <old_name> # Rename the local branch git branch -m <new_name>
2. Delete the Old Branch Remotely and Push the New Branch Name
# Delete the old branch # Push the new branch name git push origin :<old_name> <new_name>
3. Reset the Upstream Branch
# Reset the upstream git push origin -u <new_name>
Git: How to Rename a Git Branch Locally and Remotely
Be The First
Join our list to get instant access to new articles and weekly newsletter.