2

I have a repository on my machine ins /opt/git/myrepo.git

Then I have two working directories:

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

Both are cloned from /opt/git/myrepo.git

In test.mysite.com I created a new branch, called myfirstbranch and I pushed it to the repo with:

git push origin myfirstbranch

Then if I do git branch -a I see this:

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

Now if I go over to mysite.com and do git fetch then git branch -a, this is what I see:

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

So that's fine. But then if I do:

git push origin :myfirstbranch

From mysite.com and then go over to test.mysite.com and do a git fetch, then git branch -a I still see:

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

Why does it still think remotes/origin/myfirstbranch still exists? When I do git branch -a in mysite.com it doesn't show remotes/origin/myfirstbranch

Why the difference?

4

1 に答える 1

3

Branches deleted remotely are not deleted automatically in the local repo. You need to use:

git remote prune origin

Also, git remote show origin will show a nice list of remote branches, with a "need to prune" comment if needed.

于 2012-11-26T01:50:04.067 に答える