git:重命名远程分支? [英] git: renaming branches remotely?
问题描述
如果有一个仓库,我只有git://访问(并且通常只需push + pull),是否有一种方法可以重命名该仓库中的分支,方法与本地使用 git branch -m
?
您只需创建一个新的本地分支使用所需的名称,将其推送到远程,然后删除旧的远程分支:
$ git分支new-branch-名称来源/ old-branch-name
$ git push origin --set-upstream新分支名称
$ git push来源:old-branch-name
然后,要查看旧分支名称,存储库的每个客户端都必须这样做:
$ git fetch origin
$ git remote prune origin
注意:如果您的旧分支是您的主分支,您应该更改主分支设置。否则,当您运行 $ git push origin:old-branch-name
时,您将收到错误删除当前分支禁止。
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 way that I would do locally with git branch -m
?
You just have to create a new local branch with the desired name, push it to your remote, and then delete the old remote branch:
$ git branch new-branch-name origin/old-branch-name
$ git push origin --set-upstream new-branch-name
$ git push origin :old-branch-name
Then, to see the old branch name, each client of the repository would have to do:
$ git fetch origin
$ git remote prune origin
NOTE: If your old branch is your main branch, you should change your main branch settings. Otherwise, when you run $ git push origin :old-branch-name
, you'll get the error "deletion of the current branch prohibited".
这篇关于git:重命名远程分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!