2

我的机器上有一个存储库 ins /opt/git/myrepo.git

然后我有两个工作目录:

/var/www/mysite.com /var/www/test.mysite.com

两者都是从 /opt/git/myrepo.git 克隆的

在 test.mysite.com 中,我创建了一个名为 myfirstbranch 的新分支,并将其推送到 repo:

git push origin myfirstbranch

然后,如果我执行 git branch -a 我会看到:

* master
  myfirstbranch
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/myfirstbranch

现在,如果我转到 mysite.com 并执行 git fetch 然后 git branch -a,这就是我所看到的:

* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/myfirstbranch

所以没关系。但是,如果我这样做:

git push origin :myfirstbranch

从 mysite.com 然后转到 test.mysite.com 并执行 git fetch,然后 git branch -a 我仍然看到:

* master
  myfirstbranch
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/myfirstbranch

为什么它仍然认为 remotes/origin/myfirstbranch 仍然存在?当我在 mysite.com 中执行 git branch -a 时,它显示 remotes/origin/myfirstbranch

为什么有区别?

4

1 回答 1

3

远程删除的分支不会在本地存储库中自动删除。你需要使用:

git remote prune origin

此外,git remote show origin将显示一个不错的远程分支列表,如果需要,带有“需要修剪”的注释。

于 2012-11-26T01:50:04.067 回答