Renaming a branch in GitHub

前端 未结 15 2344
面向向阳花
面向向阳花 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:00

    I've found three commands on how you can change your Git branch name, and these commands are a faster way to do that:

    git branch -m old_branch new_branch         # Rename branch locally
    git push origin :old_branch                 # Delete the old branch
    git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote
    

    If you need step-by-step you can read this great article:

    How to Rename Git Local and Remote Branches

提交回复
热议问题