我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
实际上,你有三个步骤 因为本地分行服务器上有一个复制件 所以我们在服务器上的两个步骤上有一个步骤是本地分行:
git branch -m <old-branch-name> <new-branch-name>
git push <remote-name[origin by default]> :<old-branch-name>
git push -u <new-branch-name>
其他回答
重命名当前分支 :
git branch -m <newname>
将指定给任何分支的分支重新命名 :
git branch -m <oldname> <newname>
-m
短为--move
.
推动地方分支并重设上游分支:
git push origin -u <newname>
删除远程分支 :
git push origin --delete <oldname>
创建git rename
别名 :
git config --global alias.rename 'branch -m'
在 Windows 或其他不区分大小写的文件系统上使用-M
如果名称仅出现资本化变化, 则该名称只有资本化变化 。 否则, Git 将投"部门已经存在"错误 。
git branch -M <newname>
在PhpStorm中:
VCS你的支节重命名
仅三个步骤,以复制名称的更改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_name new_branch_name
上述命令将改变您的分支名称, 但你必须非常小心地使用重新命名的分支, 因为它仍然会指与其相关的旧的上游分支, 如果有的话 。
如果您想要在本地分支重新命名为新分支后将一些更改推入母版( 例如名称) :
git push origin new_branch_name:master
(现在更改将转到母版分支, 但您的本地分支名称是新_ branch_ name)
详情见 " 。如何在 Git 中重新命名您的本地分支名称."
高级 Git 用户可以手动重命名 :
Rename the old branch under .git/refs/heads to the new name
Rename the old branch under .git/logs/refs/heads to the new name
Update the .git/HEAD to point to yout new branch name