How do I rename a local Git branch?

后端 未结 30 1455
轻奢々
轻奢々 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条回答
  •  萌比男神i
    2020-11-22 12:12

    If you want to change the name of the current branch, run:

    git branch -m [old_branch] [new_branch]
    

    If you want to delete the old remote branch, run:

    git push origin :[old_branch]
    

    If you want to delete the old remote branch and create a new remote branch, run:

    git push origin :old_branch new_branch
    

提交回复
热议问题