我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
更改事务组本地本地很简单...
如果您在树枝上, 您想要更改名称, 只需这样做 :
git branch -m my_new_branch
否则,如果你在master
或任何其他事务组而不是你想改名的,简单说说:
git branch -m my_old_branch my_new_branch
此外,我创建了下面的图像 来展示在命令行。在这种情况下,你正在master
例如,分支:
其他回答
如果您想要:
git branch -m <oldname> <newname>
git push origin: old-name new-name
git commit <newname>
git push origin new_branch_name:master
git status
git checkout
如果您愿意使用源树树你可以右键单击分支并选择“改名 ” 。
有关这一程序的更多详情。
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 <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-name> <new-branch-name>
git push <remote-name[origin by default]> :<old-branch-name>
git push -u <new-branch-name>