如何强制删除GitHub中的远程分支? [英] How to forcefully delete a remote branch in GitHub?

查看:987
本文介绍了如何强制删除GitHub中的远程分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个远程分支机构:

   -  pending-issues-in-project 
- new-issues- in-project

我尝试删除 pending-issues-in-project 像这样:

git push origin:pending-issues-in-project ,但是我得到了错误:

 错误:无法推送到不合格的目的地:pending-issues-in-project 
目的地refspec既不匹配现有的ref远程$
以ref /开始,我们无法根据源参考猜测前缀。
错误:无法将一些文件推送到'git@github.com:forkedRepo / RepoName.git'

所以我想可能是我删除了 pending-issues-in-project 分支,但是当我运行

git branch -a 它显示 pending-issues-in-project 列表中的分支。

当我尝试相同(尝试删除) new-issues-in-project ,它工作。

我已经使用<$ c $从本地服务器中删除了两个分支c> git分支-D branchName 。 b
$ b


如果错误发生是因为分支不在存储库中,那么
为什么它会进入远程分支列表?



有没有办法强制删除远程分支?


感谢您的支持

解决方案

git remote prune origin

删除本地git仓库中的远程追踪分支(剪枝删除任何不存在于远程原点的分支)。之后,你不会在 git branch -a


下看到它

I have 2 remote branches :

 - pending-issues-in-project
 - new-issues-in-project

I tried to delete pending-issues-in-project like this :
git push origin :pending-issues-in-project, but i got the error :

error: unable to push to unqualified destination: pending-issues-in-project
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.  
error: failed to push some refs to 'git@github.com:forkedRepo/RepoName.git'

So i thought may be i have deleted pending-issues-in-project branch, but when i run
git branch -a it shows pending-issues-in-project branch in the list.
When i tried same (tried deleting) for new-issues-in-project, it worked.
I have already deleted both branches from local server using git branch -D branchName.

If the error is coming because the branch not exist in repository then why its coming in remote branch list?
and
Is there any way to forcefully deletion of the remote branch?

Thanks for your time.

解决方案

You have to do:

git remote prune origin

to remove that remote tracking branch in your local git repository ( prune removes any branch that does not exist in the remote origin anymore). After that, you will not see it under git branch -a

这篇关于如何强制删除GitHub中的远程分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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