我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
在视觉演播室:
· 管理处 _______________________________________________________________________________________________________________________您的仓库 → 您的分支重命名
其他回答
如果您不想将分支推到远程服务器, 这个示例将很有用 :
假设你有一个现有的分支 叫做"我的热能特长" 你想把它改名为"特长15"
首先,你想改变你的地方分支。
git branch -m my-hot-feature feature-15
更多信息,请访问地方和远程重命名Git的一个分支.
有关这一程序的更多详情。
git checkout oldbranch
git branch -m newbranch
git branch -m oldbranch newbranch
如果其他用户使用此分支并承诺执行此分支, 您应该在将其重新命名为本地之前将其拉动 。 这样可以确保您的本地仓库得到更新, 并确保其他用户所做的更改不会丢失 。
首先,我们需要删除oldbranch
从远程仓库中键,然后按enwbranch
至远程。
git push origin --delete oldbranch
使用-u(固定上游)选项,
git push origin -u newbranch
这里有三个步骤:命令, 您可以在终端内调用, 更改分支名称 。
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 分支名称这是一篇关于这个的好文章。
如果您愿意使用源树树你可以右键单击分支并选择“改名 ” 。
git branch -m <new_name>
这将为您正在工作的当前分支设定新名称 。
git branch -m <old_name> <new_name>
您必须在此提供旧的分支名称和新分支名称 。