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

相关:


当前回答

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

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

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

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

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

仅此而已。

其他回答

重命名当前分支 :

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] [new_branch]

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

git push origin :[old_branch]

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

git push origin :old_branch new_branch

要重命名本地分支 :

git branch -m [old-branch] [new-branch]

现在你也必须在远程服务器上传播这些变化。

将已删除的旧分支的更改推到下方 :

git push origin :[old-branch]

推动新分支创建的变更 :

git push origin [new-branch]

将当前分支重命名为新分支名称 :

git branch -m <new_name>

这将为您正在工作的当前分支设定新名称 。


要重命名另一个分支 :

git branch -m <old_name> <new_name>

您必须在此提供旧的分支名称和新分支名称 。