The option -M is used to force the rename even if git branch -M <oldbranchname> <newbranchname>.
You can also use -m instead of -M to rename the branch even if --move or --rename flags as aliases for -M.
When you use the this command, git also updates your tracking branch with the new name.