Renaming a branch in GitHub

前端 未结 15 2337
面向向阳花
面向向阳花 2020-12-02 03:28

I just renamed my local branch using

git branch -m oldname newname

but this only renames the local version of the branch. How can I rename

15条回答
  •  长情又很酷
    2020-12-02 04:05

    On the Git branch, run:

    git branch -m old_name  new_name
    

    This will modify the branch name on your local repository:

    git push origin :old_name new_name
    

    This will push the modified name to the remote and delete the old branch:

    git push origin -u new_name
    

    It sets the local branch to track the remote branch.

    This solves the issue.

提交回复
热议问题