我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
这里有三个步骤:命令, 您可以在终端内调用, 更改分支名称 。
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
如果需要更多的话:一步一步,如何更改 Git 分支名称这是一篇关于这个的好文章。
其他回答
要重命名当前分支( 除独立 HEAD 状态外) 您也可以使用此别名 :
[alias]
mvh = !sh -c 'git branch -m `git rev-parse --abbrev-ref HEAD` $1'
重命名本地分支GitHub 桌面桌面,单击现任分处选项卡 (当前仓库右侧) , 右键单击您想要重命名的分支, 右键单击重命名 。 然后您会被弹出提示到可以重命名的位置 。
这里有三个步骤:命令, 您可以在终端内调用, 更改分支名称 。
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
如果需要更多的话:一步一步,如何更改 Git 分支名称这是一篇关于这个的好文章。
如果您不想将分支推到远程服务器, 这个示例将很有用 :
假设你有一个现有的分支 叫做"我的热能特长" 你想把它改名为"特长15"
首先,你想改变你的地方分支。
git branch -m my-hot-feature feature-15
更多信息,请访问地方和远程重命名Git的一个分支.
如果是您的当前分支, 只需做
git branch -m new_name
如果它是另一个分支, 您想要重命名
git branch -m old_name new_name
- 如果您的分支被推动, 那么在重新命名后, 您需要从远程 Git 仓库删除它, 并要求您的新本地端跟踪新的远程分支 :
git push origin :old_name
git push --set-upstream origin new_name