我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
要重命名本地分支 :
git branch -m [old-branch] [new-branch]
现在你也必须在远程服务器上传播这些变化。
将已删除的旧分支的更改推到下方 :
git push origin :[old-branch]
推动新分支创建的变更 :
git push origin [new-branch]
其他回答
所有你必须做的是三步:
.git/refs/heads
新名称.git/logs/refs/heads
新名称.git/HEAD
导致您新分支名称这里有三个步骤:命令, 您可以在终端内调用, 更改分支名称 。
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 [old_branch_name] [new_branch_name]
-m
:它重命名/移动分支。如果已经有一个分支,则会出错。
如果已经有一个分支, 您想要用该分支重命名, 请使用 :
git rename -M [old_branch_name] [new_branch_name]
有关帮助的更多信息,请在终端中使用此命令 :
git branch --help
或
man git branch
重命名当前分支 :
git branch -m <newname>
将指定给任何分支的分支重新命名 :
git branch -m <oldname> <newname>
-m
短为--move
.
推动地方分支并重设上游分支:
git push origin -u <newname>
删除远程分支 :
git push origin --delete <oldname>
创建git rename
别名 :
git config --global alias.rename 'branch -m'
在 Windows 或其他不区分大小写的文件系统上使用-M
如果名称仅出现资本化变化, 则该名称只有资本化变化 。 否则, Git 将投"部门已经存在"错误 。
git branch -M <newname>
如果您想要更改分支的名称
git 分支 - m 新名称