Use git command line (with git bash on Windows) to change the branch name.
1 – Be sure you are on the right branch
Firstly, you should be on your current branch (the branch you want to rename) with git checkout.
2 – Change the name of the branch locally
Secondly, you should rename the branch with the following command:
git branch -m <the_new_branch_name>
The new branch name should be valid, with no space. If you use special characters you should use quotes like:
git branch -m “let’s-put-a-complicated-name”
3 – Change the name of the branch remotely
You can now change the name of the branch remotely so it’s also changed on github / gitlab / bitbucket etc.
To do push it use:
git push origin HEAD:<old_branch_name>
If it’s a complicated name you can still use the quotes:
git push origin HEAD:”it’s-an-old-branch-name”