这就是我正在做的......如何摆脱原始远程分支?它是什么?
[master] /dir: git status
# On branch master
nothing to commit (working directory clean)
[master] /dir: git remote show
github
[master] /dir: git branch -r
github/master
origin/HEAD -> origin/master
[master] /dir: git branch -rd origin/HEAD
error: remote branch 'origin/HEAD' not found.
[master] /dir: git branch -rd origin
error: remote branch 'origin' not found.
[master] /dir: git branch -rd origin/HEAD -> origin/master
-bash: origin/master: No such file or directory
[master] /Applications/MAMP/htdocs/asanawww: git branch -rd origin/master
error: remote branch 'origin/master' not found.
[master] /Applications/MAMP/htdocs/asanawww: git push origin :master
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
我也试过
git gc --prune=now
没有运气
答案 0 :(得分:4)
答案 1 :(得分:3)
你应该这样做:
git branch -rd origin/master
考虑到此命令将在本地删除远程分支,即存储库中保存的“origin / master”引用。如果遥控器中仍存在该分支,则在有拉或取指令时,将再次创建“origin / master”引用。
要从遥控器中正确删除它,您可以使用:
git push origin :master
此<local>:<remote>
表示法意味着<local>
引用将作为<remote>
分支推送。通过使用:master
,您的意思是“无引用”将被推送为主,因此将其删除。
另一种选择是删除推送:
git push --delete origin master
答案 2 :(得分:0)
也许您需要删除与本地分支关联的工作树(以防它被检入另一个目录)
git worktree remove work-tree-directory --force //use force if its dirty
然后您可以使用
删除分支 git branch -D branch-to-delete // -D is for force delete, for normal use -d