我如何重命名尚未被推到远程仓库的本地分支 ?
相关:
当前回答
如果您想要:
git branch -m <oldname> <newname>
git push origin: old-name new-name
git commit <newname>
git push origin new_branch_name:master
git status
git checkout
其他回答
一个简单的方法来做到这一点:
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 <new_name>
git push origin :<old_name>
git push origin <new_name>:refs/heads/<new_name>
EDIT(12/01/2017):确保您运行命令git status
并检查新创建的分支指向的是它自己的参考文献,而不是旧的参考文献。如果找到旧分支的引用文献,您需要解开上游的设置,使用 :
git branch --unset-upstream
在视觉演播室:
· 管理处 _______________________________________________________________________________________________________________________您的仓库 → 您的分支重命名
另一个选项是根本不使用命令行。 Git GUI 客户端,例如源树树导致像这个这样的问题 成为Stack overflow最受关注的问题之一。
在 SourceTree 中,右键单击左侧“ Branches” 窗格中的任何本地分支并选择“ 重命名... ” 。
我愚蠢地命名了一个树枝 从连字符开始, 然后检查了主人。删除删除我的分支,我有工作在里面。
这两种办法都行不通:
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