在git仓库中切换当前分支 [英] Switch current branch in git bare repository
本文介绍了在git仓库中切换当前分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我实际上想删除我正在使用的裸仓库中的一个分支,但是这个任务已经到了死胡同的地步,因为如果没有裸仓库不具备的工作树,我无法从主仓库切换。 / p>
当我运行 git branch -d master
时,输出结果为:
错误:无法删除当前所在的分支'master'。
所以我尝试通过运行 git切换到另一个名为'develop'的分支checkout开发
,输出结果为:
致命:该操作必须在工作树中运行
解决方案
试试这个而不是 git checkout
:
git symbolic-ref HEAD refs / heads / develop
然后你应该可以删除master。
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:
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:
fatal: This operation must be run in a work tree
解决方案
Try this instead of git checkout
:
git symbolic-ref HEAD refs/heads/develop
Then you should be able to delete master.
这篇关于在git仓库中切换当前分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文