Search code examples
gitgit-branchgit-remote

Removed remote. But remote branch still shows


I've added a remote, so I could checkout a coworker's code.

$ git remote add coworker git@ourgitserver.local:...
$ git fetch coworker
$ git checkout coworker/theirbranch
$ git checkout -b mycopy

The code looked good. So I do some cleanup:

$ git checkout master
$ git remote remove coworker
$ git branch -D mycopy

But their remote branch still shows up:

$ git branch -a
remotes/coworker/theirbranch

I've done git fetch -p --all, git gc --prune=now and those did nothing.

I can't do git branch -D coworker/theirbranch because the remote doesn't exist. Neither can I git fetch -p coworker because that remote does not exist.

Any ideas?


Solution

  • The git remote remove coworker should have deleted the corresponding remote-tracking branches, and does in the quick tests I ran, so I am not sure what went wrong here.

    To manually clean up, though, you may run git branch -d -r (note both flags) on each remaining remote-tracking branch:

    git branch -d -r coworker/theirbranch