Change a branch name in a Git repo

后端 未结 2 1783
迷失自我
迷失自我 2021-01-29 17:54

How do I rename an existing branch in a Git repo?

I want the current branch to have a new name.

2条回答
  •  爱一瞬间的悲伤
    2021-01-29 18:37

    Assuming you're currently on the branch you want to rename:

    git branch -m newname
    

    This is documented in the manual for git-branch, which you can view using

    man git-branch
    

    or

    git help branch
    

    Specifically, the command is

    git branch (-m | -M) [] 
    

    where the parameters are:

       
           The name of an existing branch to rename.
    
       
           The new name for an existing branch. The same restrictions as for  apply.
    

    is optional, if you want to rename the current branch.

提交回复
热议问题