我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
当前回答
试图具体回答问题(至少是标题)。
您也可以重命名本地分支,但继续跟踪远程的旧名称。
git branch -m old_branch new_branch
git push --set-upstream origin new_branch:old_branch
现在,当您运行 Git 推时, 远程的老管区ref 用您的本地新管区更新 。
您必须知道并记住这个配置。 但如果您没有选择远程分支名称的选择, 它可能会有用, 但是您不喜欢它( 您有一个很好的理由不喜欢它! ) 并且更喜欢您本地分支更清晰的名称 。
使用抓取配置, 您甚至可以重命名本地远程参考 。 也就是说, 拥有分支的 refs/ remote/ broot/ new_ branch ref 指针, 事实上就是原发的旧分队。 但是, 我非常不鼓励您这样做, 以保障您心灵的安全 。
其他回答
在PhpStorm中:
VCS
高级 Git 用户可以手动重命名 :
Rename the old branch under .git/refs/heads to the new name
Rename the old branch under .git/logs/refs/heads to the new name
Update the .git/HEAD to point to yout new branch name
如果您想要:
重命名 Git 仓库, 运行 : git 分支 - m <oldname> < newname> 以下列方式删除旧分支 : git 推进源 : 旧名称的新名称使用 : git 承诺 < newname> , 然后使用 : git 推进源 New_ branch_ name: master 如果您想要检查状态, 那么使用 : git 状态 如果您想要检查是否退出, 那么使用: git 检查退出
使用此命令重命名分支 :
git branch -m [old_branch_name] [new_branch_name]
- m: 它重命名/ 移动分支。 如果已经有一个分支, 您将会出错 。
如果已经有一个分支, 您想要用该分支重命名, 请使用 :
git rename -M [old_branch_name] [new_branch_name]
有关帮助的更多信息,请在终端中使用此命令 :
git branch --help
或
man git branch
重命名本地分支 : git 分支 -m <old_branch_name_name> <new_branch_name> 按下新分支 : git 推 -- set- 上流来源 < new_ branch_ name>