我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
当前回答
在PhpStorm中:
VCS
其他回答
重命名当前分支 :
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>
在PhpStorm中:
VCS
2.9.2 Git 版本
如果您想要更改本地分支的名称, 请在 :
git branch -m new_name
如果您想要更改另一分支的名称 :
git branch -m old_name new_name
如果您想要将其它分支的名称更改为已经存在的名称 :
git branch -M old_name new_name_that_already_exists
注意: 最后一个命令是破坏性的, 将会重新命名您的分支, 但是您会丢失旧分支, 并且会丢失旧分支, 因为分支名称必须是独一无二的 。
所有你必须做的是三步:
在.git/refs/head 下给旧分支以.git/refs/head 下的新名称 给旧分支以.git/log/refs/head 下的新名称 更新 .git/HEAD 以导致您的新分支名称 。
吉特・伊特的反派命令 试试这个 对我有用
默认分支已被重新命名 ! { oldBranchName} 现在命名为{ newBranchName} 如果您有本地克隆, 您可以运行以下命令来更新它 。
git branch -m {oldBranchName} {NewBranchName}
git fetch origin
git branch -u origin/{NewBranchName} {NewBranchName}
git remote set-head origin -a