我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
当前回答
重新命名您的本地分支 。
如果您在分支上, 您想要重命名 :
git branch -m new-name
如果在另一分支上:
git branch -m old-name new-name
删除旧名称远程分支并按下新名称本地分支 。
git 推推源: old- name new- name
重置新命名本地分支的上游分支。 切换到分支, 然后 :
git 推进源 - u new- name
或者为了快速地做到这一点 你可以使用这三步:
# 本地重命名分支
git branch -m old_branch new_branch
# 删除旧的远程分支
git push origin :old_branch
# 推动新分支, 设置本地分支以跟踪新远程
git push --set-upstream origin new_branch
参考文献:https://www.w3docs.com/snippets/git/how-to-rename-git-local-and-remote-branches.html
其他回答
git branch -m [old-branch] [new-branch]
-m 意指全部从[旧部门]移动到[新部门],并记住您可以使用 -M 用于其他文件系统。
要重命名您的当前分支 :
git branch -m <newname>
重命名本地分支 : git 分支 -m <old_branch_name_name> <new_branch_name> 按下新分支 : git 推 -- set- 上流来源 < new_ branch_ name>
在视觉演播室:
Git 管理分支 支部 你的仓库 你的支部 重命名
高级 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