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

相关:


当前回答

所有你必须做的是三步:

  1. 给旧分支下.git/refs/heads新名称
  2. 给旧分支下.git/logs/refs/heads新名称
  3. 更新.git/HEAD导致您新分支名称

其他回答

如果您想要:

  • 重命名 Git 仓库, 运行 :git branch -m <oldname> <newname>
  • 删除旧分支 :git push origin: old-name new-name
  • 提交使用 :git commit <newname>
    • 并按下使用 :git push origin new_branch_name:master
  • 如果您想要检查状态, 请使用 :git status
  • 如果您想要检查退出, 请使用 :git checkout

一个简单的方法来做到这一点:

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

更多信息这笔.

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

  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>
    

在PhpStorm中:

VCS你的支节重命名

仅三个步骤,以复制名称的更改remote以及基特胡卜人的故事:

步骤1git branch -m old_branchname new_branchname

步骤2git push origin :old_branchname new_branchname

步骤3git push --set-upstream origin new_branchname