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

相关:


当前回答

仅三个步骤,以复制名称的更改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 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 分支名称这是一篇关于这个的好文章。

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

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

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

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

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

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

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

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

可能正如其他人所提到的那样,这将是分支命名中出现的情况不匹配。

如果你有这样的情况,我可以猜测 你在Windows上,这也将导致你:

$ git branch -m CaseSensitive casesensitive
fatal: A branch named 'casesensitive' already exists.

然后,你必须做一个中间步骤:

$ git branch -m temporary
$ git branch -m casesensitive

仅此而已。