我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
使用此命令重命名分支 :
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]
现在你也必须在远程服务器上传播这些变化。
将已删除的旧分支的更改推到下方 :
git push origin :[old-branch]
推动新分支创建的变更 :
git push origin [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 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 checkout -dumb-name
git checkout -- -dumb-name
"
s,'
s 和 s , s 和 s\
也没有帮助。git branch -m
没有工作。
我终于把它修好了。 进入您的工作副本 . git/ refs/ heads, 找到文件名“ - dumb- name ” , 获取分支的大麻。 然后, 这将检查它, 制造一个新的有正常名称的分支, 并删除旧的分支 。
git checkout {hash}
git checkout -b brilliant-name
git branch -d -- -dumb-name
重命名本地分支GitHub 桌面桌面,单击现任分处选项卡 (当前仓库右侧) , 右键单击您想要重命名的分支, 右键单击重命名 。 然后您会被弹出提示到可以重命名的位置 。