How do I rename a local Git branch?

后端 未结 30 1197
轻奢々
轻奢々 2020-11-22 11:48

I don\'t want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.

How can I rename a local branch wh

30条回答
  •  逝去的感伤
    2020-11-22 12:07

    A simple way to do it:

    git branch -m old_branch new_branch         # Rename branch locally
    git push origin :old_branch                 # Delete the old branch
    git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote
    

    For more, see this.

提交回复
热议问题