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

相关:


当前回答

如果您不想将分支推到远程服务器, 这个示例将很有用 :

假设你有一个现有的分支 叫做"我的热能特长" 你想把它改名为"特长15"

首先,你想改变你的地方分支。

git branch -m my-hot-feature feature-15

更多信息,请访问地方和远程重命名Git的一个分支.

其他回答

如果您愿意使用源树树你可以右键单击分支并选择“改名 ” 。

enter image description here

这里有三个步骤:命令, 您可以在终端内调用, 更改分支名称 。

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 my_new_branch

否则,如果你在master任何其他事务组而不是你想改名的,简单说说:

git branch -m my_old_branch my_new_branch

此外,我创建了下面的图像 来展示在命令行。在这种情况下,你正在master例如,分支:

Change branch name locally

要重命名当前分支( 除独立 HEAD 状态外) 您也可以使用此别名 :

[alias]
    mvh = !sh -c 'git branch -m `git rev-parse --abbrev-ref HEAD` $1'

要重命名您的当前分支 :

git branch -m <newname>