我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
如果您想要更改分支的名称
git 分支 - m 新名称
其他回答
如果您想要更改当前分支的名称,请运行 :
git branch -m [old_branch] [new_branch]
如果您想要删除旧的远程分支,请运行 :
git push origin :[old_branch]
如果您想要删除旧的远程分支并创建一个新的远程分支,请运行 :
git push origin :old_branch new_branch
吉特・伊特的反派命令 试试这个 对我有用
默认分支已被重新命名 ! { oldBranchName} 现在命名为{ newBranchName} 如果您有本地克隆, 您可以运行以下命令来更新它 。
git branch -m {oldBranchName} {NewBranchName}
git fetch origin
git branch -u origin/{NewBranchName} {NewBranchName}
git remote set-head origin -a
更改事务组本地本地很简单...
如果您在树枝上, 您想要更改名称, 只需这样做 :
git branch -m my_new_branch
否则,如果你在master
或任何其他事务组而不是你想改名的,简单说说:
git branch -m my_old_branch my_new_branch
此外,我创建了下面的图像 来展示在命令行。在这种情况下,你正在master
例如,分支:
有关这一程序的更多详情。
git checkout oldbranch
git branch -m newbranch
git branch -m oldbranch newbranch
如果其他用户使用此分支并承诺执行此分支, 您应该在将其重新命名为本地之前将其拉动 。 这样可以确保您的本地仓库得到更新, 并确保其他用户所做的更改不会丢失 。
首先,我们需要删除oldbranch
从远程仓库中键,然后按enwbranch
至远程。
git push origin --delete oldbranch
使用-u(固定上游)选项,
git push origin -u newbranch
使用此命令重命名分支 :
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