tags:

views:

32

answers:

3

In a git repository, a remote branch I am not tracking was deleted. When I type

git branch -r

the deleted branch still shows up (and I can check it out)

What git command do I have to run to update this info?

+1  A: 

You can combine the -r and -d flags to delete remote branches.

mikerobi
great tip! however, in this case, there are several branches that were already deleted, surely there is a command to fetch these updates
Bain Markev
+2  A: 

If you perform something like

git branch -d -r remote_name/branch_name

you only remove your local checkout. This command doesn't do anything to the remote repository, which is why it still shows up.

Solution:

git push origin :branch_name

will remove the the remote branch (note the ':'), and

git branch -d branch_name

will remove your local checkout.

(Reference)

Garrett Hyde
You can also run 'git remote prune origin' to clean-up your remote references.
Casey
That will remove all branches that are no longer tracked by the remote repository. So, just be careful.
Garrett Hyde
A: 

If it were branches in remote repository that got deleted, and you want to update all local remote-tracking branches at once, you can use

$ git remote prune <remotename>

to delete all stale remote-tracking branches for a given remote (i.e. those that follow branches which were removed in remote repository).

See git remote documentation.

Jakub Narębski