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

相关:


当前回答

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

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 [old_branch_name] [new_branch_name]

-m:它重命名/移动分支。如果已经有一个分支,则会出错。

如果已经有一个分支, 您想要用该分支重命名, 请使用 :

 git rename -M [old_branch_name] [new_branch_name]

有关帮助的更多信息,请在终端中使用此命令 :

git branch --help

man git branch

如果您想要更改当前分支的名称,请运行 :

git branch -m [old_branch] [new_branch]

如果您想要删除旧的远程分支,请运行 :

git push origin :[old_branch]

如果您想要删除旧的远程分支并创建一个新的远程分支,请运行 :

git push origin :old_branch new_branch

更改事务组本地本地很简单...

如果您在树枝上, 您想要更改名称, 只需这样做 :

git branch -m my_new_branch

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

git branch -m my_old_branch my_new_branch

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

Change branch name locally

吉特・伊特的反派命令 试试这个 对我有用

默认分支已被重新命名 ! { oldBranchName} 现在命名为{ newBranchName} 如果您有本地克隆, 您可以运行以下命令来更新它 。

git branch -m {oldBranchName} {NewBranchName}
git fetch origin
git branch -u origin/{NewBranchName} {NewBranchName}
git remote set-head origin -a

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

enter image description here