在 git 裸仓库中切换当前分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4468322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Switch current branch in git bare repository
提问by Ankur
I actually want to remove a branch in the bare repository i am working with, but this task hits a dead end because I cannot switch away from the master repository without a 'work tree' which a bare repository does not have.
我实际上想删除我正在使用的裸存储库中的一个分支,但是这个任务遇到了死胡同,因为如果没有裸存储库没有的“工作树”,我无法从主存储库切换。
When I run git branch -d master
the output is:
当我运行时git branch -d master
,输出是:
error: Cannot delete the branch 'master' which you are currently on.
So I try to switch to another branch called 'develop' by running git checkout develop
and the output is:
所以我尝试通过运行切换到另一个名为“develop”的分支git checkout develop
,输出是:
fatal: This operation must be run in a work tree
回答by cdhowie
Try this instead of git checkout
:
试试这个而不是git checkout
:
git symbolic-ref HEAD refs/heads/develop
Then you should be able to delete master.
然后你应该可以删除master。