Renaming branches remotely in Git

后端 未结 9 1186
执笔经年
执笔经年 2020-11-28 17:07

If there is a repository that I only have git:// access to (and would usually just push+pull), is there a way to rename branches in that repository in the same

9条回答
  •  一整个雨季
    2020-11-28 17:44

    I don't know why but @Sylvain Defresne's answer does not work for me.

    git branch new-branch-name origin/old-branch-name
    git push origin --set-upstream new-branch-name
    git push origin :old-branch-name
    

    I have to unset the upstream and then I can set the stream again. The following is how I did it.

    git checkout -b new-branch-name
    git branch --unset-upstream
    git push origin new-branch-name -u
    git branch origin :old-branch-name
    

提交回复
热议问题