我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
重命名本地和远程 Git 仓库的主分支 ?
当前回答
在PhpStorm中:
VCS
其他回答
使用此命令重命名分支 :
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 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 branch -m my_new_branch
否则,如果你是主人 或任何其他分支 除了你想改名的分支, 简单做:
git branch -m my_old_branch my_new_branch
另外,我在下面创建图像, 以在命令行的操作中显示此图像。 在这种情况下, 您在主分支中, 例如 :
调
将当前分支重命名为新分支名称 :
git branch -m <new_name>
这将为您正在工作的当前分支设定新名称 。
要重命名另一个分支 :
git branch -m <old_name> <new_name>
您必须在此提供旧的分支名称和新分支名称 。
如果您愿意使用 SourceTree (我强烈建议), 您可以右键单击分支并选择“ 改名 ” 。
调