在git仓库中切换当前分支

在git仓库中切换当前分支

本文介绍了在git仓库中切换当前分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上想删除我正在使用的裸仓库中的一个分支,但是这个任务已经到了死胡同的地步,因为如果没有裸仓库不具备的工作树,我无法从主仓库切换。 / p>

当我运行

试试这个而不是 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仓库中切换当前分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 08:07