How do I rename a local Git branch?

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

    Rename the branch using this command:

    git branch -m [old_branch_name] [new_branch_name]
    

    -m: It renames/moves the branch. If there is already a branch, you will get an error.

    If there is already a branch and you want to rename with that branch, use:

     git rename -M [old_branch_name] [new_branch_name]
    

    For more information about help, use this command in the terminal:

    git branch --help
    

    or

    man git branch
    

提交回复
热议问题