使用Git删除本地分支 [英] Deleting a local branch with Git

查看:650
本文介绍了使用Git删除本地分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Google搜索过,关于这个话题有很长的话题,但似乎没有一个有用的线索.我想我做错了. 我有一个名为Test_Branch的分支.当我尝试使用推荐方法将其删除时,出现以下错误:

I've googled and there are several very long threads on this topic and none of them seem to help. I think I'm doing something wrong. I have a branch called Test_Branch. When I try to delete it using the recommend method, I get the following error:

无法删除在[[目录]中签出的分支'Test_Branch' 位置]".

Cannot delete branch 'Test_Branch' checked out at '[directory location]'.

除此之外,我没有其他信息.我可以轻松删除远程分支,但本地分支不会消失.

I get no other information besides that. I can blow away the remote branch easy but the local branch won't go away.

推荐答案

切换到其他分支并删除Test_Branch,如下所示:

Switch to some other branch and delete Test_Branch, as follows:

$ git checkout master
$ git branch -d Test_Branch

如果以上命令给您错误-The branch 'Test_Branch' is not fully merged. If you are sure you want to delete it并且仍然要删除它,则可以使用-D而不是-d强制删除它,如下:

If above command gives you error - The branch 'Test_Branch' is not fully merged. If you are sure you want to delete it and still you want to delete it, then you can force delete it using -D instead of -d, as:

$ git branch -D Test_Branch

要同时从远程删除Test_Branch,请执行:

To delete Test_Branch from remote as well, execute:

git push origin --delete Test_Branch

这篇关于使用Git删除本地分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆