Renaming a branch in GitHub

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

    This article shows how to do it real easy.

    1. To rename a local Git branch, we can use the Git branch -m command to modify the name:

       git branch -m feature1 feature2
      
    2. If you’re just looking for the command to rename a remote Git branch, this is it:

       git push -u origin feature2:feature3
      

      Check that you have no tags on the branch before you do this. You can do that with git tag.

    0 讨论(0)
  • 2020-12-02 04:23

    Here is what worked for me:

    1. Create the new branch first:

      git push github newname :refs/heads/newname
      
    2. On the GitHub site, go to settings and change the Default branch to newname

    3. Delete the oldname

      git push github --delete oldname
      
    0 讨论(0)
  • 2020-12-02 04:24

    The following commands worked for me:

    git push origin :old-name-of-branch-on-github
    git branch -m old-name-of-branch-on-github new-name-for-branch-you-want
    git push origin new-name-for-branch-you-want
    
    0 讨论(0)
提交回复
热议问题