为什么我在本地看到更多的远程分支然后我在github上了?

时间:2016-12-22 09:38:15

标签: git github branch

我在github上托管了一个git repo。当我在本地git branch时,我只得到你在下面的输出中看到的三个分支:

$ git fetch
$ git branch
* develop
  kramer65/feature-branch
  master

然后我登录到github并在那里我看到它只有5个分支:

enter image description here

所以现在我在本地做了一个git branch -a,它显示了我的3个本地分支,以及大约40个远程分支:

enter image description here

然后我尝试删除其中一个远程分支,但我不能:

$ git push origin :kramer65-feature-branch
error: unable to delete 'kramer65-feature-branch': remote ref does not exist
error: failed to push some refs to 'git@github.com:MyOrganisation/therepo.git'

知道为什么我仍然会看到git branch -a的这些回购?

2 个答案:

答案 0 :(得分:3)

一种可能的情况是有人为开发创建分支,您运行:

git fetch

将获取所有这些分支。合并该功能分支后,它们将被删除,而git fetch并未将其删除。你需要

git fetch -p

git fetch --prune

答案 1 :(得分:2)

您需要remove对遥控器remote-tracking的所有no longer exist个引用。

试试这个:

$ git fetch --prune
$ git branch -a

# more info
$ git fetch --help