我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
当前回答
一个简单的方法来做到这一点:
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 <newname>
将指定给任何分支的分支重新命名 :
git branch -m <oldname> <newname>
- M是短的 -移动。
推动地方分支并重设上游分支:
git push origin -u <newname>
删除远程分支 :
git push origin --delete <oldname>
要创建 git 重命名别名 :
git config --global alias.rename 'branch -m'
在 Windows 或其他不区分大小写的文件系统上, 如果名称中仅出现大小写变化, 请使用 - M 。 否则, Git 会丢弃一个“ 分支已经存在” 错误 。
git branch -M <newname>
如果您想要更改分支的名称
git branch -m newname
实际上,你有三个步骤 因为本地分行服务器上有一个复制件 所以我们在服务器上的两个步骤上有一个步骤是本地分行:
重命名本地 : 只要使用以下命令重命名您的当前分支, 甚至您检查了它 : git 分支 - m < old- branch- name > < new- branch- name > < new- branch- name > 删除服务器 1 : 使用以下命令删除服务器上的旧名称分支 : git push < remote- name[默认发自] > : <old- branch- name> 推动新分支 : 现在是时候推动服务器上的新分支了 : git push - u < new- branch- name >
在PhpStorm中:
VCS