rename github branch name code example

Example 1: how to change branch name in github

$ git branch -m OLD-BRANCH-NAME NEW-BRANCH-NAME
$ git fetch origin
$ git branch -u origin/NEW-BRANCH-NAME NEW-BRANCH-NAME

Example 2: rename local branch github

git branch -m oldname newname

Example 3: rename remote branch in git

git push origin :<branch_to_rename>
git checkout -b <new_branch_name>
git push --set-upstream origin <new_branch_name>

Example 4: how to change branch name

Rename a local and remote branch in git
Rename your local branch. If you are on the branch you want to rename: git branch -m new-name. ...
Delete the old-name remote branch and push the new-name local branch. git push origin :old-name new-name.
Reset the upstream branch for the new-name local branch. Switch to the branch and then: git push origin -u new-name.