Git rename a branch(locally and remotely)

Rename a branch in Git locally and remotely.

Rename a branch(locally and remotely)

1
2
3
4
5
6
7
8
9
10
11
# Rename a branch locally
git branch -m old-branch new-branch

# Delete the remote branch
git push origin --delete old-branch

# Unset the upstream branch
git branch --unset-upstream

# Push the new branch to remote
git push origin new-branch