我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
另一个选项是根本不使用命令行。 Git GUI 客户端,例如源树树导致像这个这样的问题 成为Stack overflow最受关注的问题之一。
在 SourceTree 中,右键单击左侧“ Branches” 窗格中的任何本地分支并选择“ 重命名... ” 。
其他回答
另一个选项是根本不使用命令行。 Git GUI 客户端,例如源树树导致像这个这样的问题 成为Stack overflow最受关注的问题之一。
在 SourceTree 中,右键单击左侧“ Branches” 窗格中的任何本地分支并选择“ 重命名... ” 。
重命名当前分支 :
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>
一个简单的方法来做到这一点:
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 branch -m <old_branch_name> <new_branch_name>
按下新分支 :
git push --set-upstream origin <new_branch_name>
更改事务组本地本地很简单...
如果您在树枝上, 您想要更改名称, 只需这样做 :
git branch -m my_new_branch
否则,如果你在master
或任何其他事务组而不是你想改名的,简单说说:
git branch -m my_old_branch my_new_branch
此外,我创建了下面的图像 来展示在命令行。在这种情况下,你正在master
例如,分支: