How do I rename a local Git branch?

后端 未结 30 1166
轻奢々
轻奢々 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:13

    Changing the branch locally is quite easy...

    If you are on the branch you want to change the name for, simply do this:

    git branch -m my_new_branch
    

    Otherwise, if you are on master or any other branch other than the one you'd like to change the name, simply do:

    git branch -m my_old_branch my_new_branch
    

    Also, I create the image below to show this in action on a command line. In this case, you are on master branch, for example:

提交回复
热议问题