我如何重命名尚未被推到远程仓库的本地分支 ?

相关:


当前回答

一个简单的方法来做到这一点:

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

更多信息这笔.

其他回答

仅三个步骤,以复制名称的更改remote以及基特胡卜人的故事:

步骤1git branch -m old_branchname new_branchname

步骤2git push origin :old_branchname new_branchname

步骤3git push --set-upstream origin new_branchname

在视觉演播室:

· 管理处 _______________________________________________________________________________________________________________________您的仓库您的分支重命名

git branch -m [old-branch] [new-branch]

-m 意指全部从[旧部门]移动到[新部门],并记住您可以使用 -M 用于其他文件系统。

重命名本地分支GitHub 桌面桌面,单击现任分处选项卡 (当前仓库右侧) , 右键单击您想要重命名的分支, 右键单击重命名 。 然后您会被弹出提示到可以重命名的位置 。

enter image description here

2.9.2 Git 版本

如果您想要更改本地分支的名称, 请在 :

git branch -m new_name

如果您想要更改另一分支的名称 :

git branch -m old_name new_name

如果您想要将其它分支的名称更改为已经存在的名称 :

git branch -M old_name new_name_that_already_exists

注意: 最后一个命令是破坏性的, 将会重新命名您的分支, 但是您会丢失旧分支, 并且会丢失旧分支, 因为分支名称必须是独一无二的 。