To change the name of a branch on both your local and remote git repository is just a few commands away.

First you need to switch to the branch you want to rename using this command

git checkout branch-name

After switching you now have to rename the branch on your local git repository using this command

git branch -m new-name

After renaming, you have to delete the old branch on your remote repository

git push origin --delete old-branch-name

Now that you have deleted the old branch from your remote repository, you can now push the new branch to your repository.

git push origin new-branch-name

And that’s it. I hope this helps.

Categorized in: