在远程分支列表下合并和删除分支后仍然可以看到Git分支 [英] Git Branch is still seen after merging and deleting branches under remote branch list

查看:192
本文介绍了在远程分支列表下合并和删除分支后仍然可以看到Git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个自动化套件,在那里我创建了两个分支p2pOnOff和release分支。

后来我将它们合并为master删除他们使用下面的命令

  git branch -d p2pOnOff 
git push origin:p2pOnOff

我发现这些分支在github.com上看不到。



我无法弄清为什么我仍然看到他们在我的电脑上被列为远程分支机构

  $ git branch --remote 
origin / HEAD - >原产地/主产地
产地/主产地
产地/ p2pOnOff
产地/产地



  $ git remote prune remotes / origin 

如果我尝试修剪/删除它, / p2pOnOff
致命:'remotes / origin / p2pOnOff'似乎不是git存储库
致命:无法从远程存储库读取。

请确保您拥有正确的访问权限
并存在存储库。

我在这里错过了什么?如何摆脱它们?我已经试过 git fetch git remote update ,他们没有帮助!!



我知道,删除整个文件夹并再次克隆它可以完成这项工作。但是我急于想知道是否有其他解决方案?

  git fetch --prune origin $ b =h2_lin>解决方案

$ b

它适用于您的情况。



git fetch 手册页:

  -p, - 修剪
提取后,移除远程不再存在的所有远程追踪分支。

要删除遥控器上的ref,您还可以使用 git push --delete ,它修剪本地引用。


I'm working on an automation suite, where I have created two branches "p2pOnOff" and "release" branches.

Later I have merged them to master and deleted them using below commands

git branch -d p2pOnOff
git push origin :p2pOnOff

I see that these branches are no more seen in github.com

I'm not able to figure out why I still see them listed as remote branches on my computer

$ git branch --remote
  origin/HEAD -> origin/master
  origin/master
  origin/p2pOnOff
  origin/release

If I try to prune/delete it, I'm getting below error:

$ git remote prune remotes/origin/p2pOnOff
fatal: 'remotes/origin/p2pOnOff' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What am I missing here? How to get rid of them? I have already tried git fetch and git remote update, they didn't help !!

I know, deleting entire folder and cloning it again does the job.. But I'm eager to know if there is any other solution??

解决方案

Have you tried:

git fetch --prune origin

it works for me in your case.

From the git fetch man-page:

-p, --prune
After fetching, remove any remote-tracking branches which no longer exist on the remote.

To delete refs on remotes you can also use git push --delete which does prune the local reference.

这篇关于在远程分支列表下合并和删除分支后仍然可以看到Git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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