如何重命名本地 Git 分支?

How do I rename the local Git branch?

我不想重命名远程分支,如 Rename master branch for both local and remote Git repositories.

中所述

如何重命名尚未推送到远程分支的本地分支?

如果您还需要重命名远程分支:

git checkout <old_branch>

git branch -m <new_branch>

git push origin -u <new_branch>