我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
当前回答
将当前分支重命名为新分支名称 :
git branch -m <new_name>
这将为您正在工作的当前分支设定新名称 。
要重命名另一个分支 :
git branch -m <old_name> <new_name>
您必须在此提供旧的分支名称和新分支名称 。
其他回答
在视觉演播室:
Git 管理分支 支部 你的仓库 你的支部 重命名
将当前分支重命名为新分支名称 :
git branch -m <new_name>
这将为您正在工作的当前分支设定新名称 。
要重命名另一个分支 :
git branch -m <old_name> <new_name>
您必须在此提供旧的分支名称和新分支名称 。
要重命名本地分支 :
git branch -m [old-branch] [new-branch]
现在你也必须在远程服务器上传播这些变化。
将已删除的旧分支的更改推到下方 :
git push origin :[old-branch]
推动新分支创建的变更 :
git push origin [new-branch]
如果您愿意使用 SourceTree (我强烈建议), 您可以右键单击分支并选择“ 改名 ” 。
调
高级 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