git branch -M <branchname>

Forcefully rename the current branch to <branchname>

The option -M is used to force the rename even if already exists. If you want to rename a branch that is not the current branch, you can use git branch -M <oldbranchname> <newbranchname>.

You can also use -m instead of -M to rename the branch even if already exists, but it will not warn if doesn't exist. Additionally, you can use the --move or --rename flags as aliases for -M.

When you use the this command, git also updates your tracking branch with the new name.