Git does not automatically delete (local) remote tracking branches if the branch is deleted in the remote repository. Also, before the V2.0.1 remote tracking branches were not deleted in some cases when you deleted the deleted file from the git configuration (see VonC answer).
To remove old branches of remote tracking (branches deleted in a remote repository) for one of your remote repositories, run
git remote prune <remote>
To git remote page or git remote :
undercut
Deletes all branches of tracking branches under <name>. These obsolete branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes / <name>".
With the --dry-run option, tell which branches will be trimmed, but do not actually trim them.
However, from your question, it seems that you manually deleted .git/refs/remotes/theoldremote , so git no longer knows about the remote repository to which the remote tracking branches belong. This is not how you should do it.
The usual way to delete a remote repository is to run
git remote rm <remote>
This will remove the remote from your .git/config and delete the remote tracking branches.
If you just delete the directory under .git/refs/remotes/ , the branches will be left behind. Then you will need to delete them manually:
git branch -rd <remote>/<branchname>
You need the -r option to delete the remote branch.
sleske Jul 04 '13 at 13:42
source share