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

相关:


当前回答

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

enter image description here

其他回答

在视觉演播室:

· 管理处 _______________________________________________________________________________________________________________________您的仓库您的分支重命名

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

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

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

要重命名本地分支 :

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

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

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

git push origin :[old-branch]

推动新分支创建的变更 :

git push origin [new-branch]

重命名当前分支 :

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>

实际上,你有三个步骤 因为本地分行服务器上有一个复制件 所以我们在服务器上的两个步骤上有一个步骤是本地分行:

  1. 重命名本地 :只需使用以下命令来重命名您当前分支的名称, 即使您检查了 :
    git branch -m <old-branch-name> <new-branch-name>
    
  2. 删除服务器 1 :使用以下命令删除服务器上的旧名称分支 :
    git push <remote-name[origin by default]> :<old-branch-name>
    
  3. 推新的一条:现在该是推动服务器上命名的新分支的时候了:
    git push -u <new-branch-name>