Alex Rivera | Logout

Git remote branch deleted, but still it appears in 'branch -a'

Asked 2011-02-23T17:10:57.700
849

Let's say I had a branch named coolbranch in my repository.

Now, I decided to delete it (both remotely and locally) with:

git push origin :coolbranch
git branch -D coolbranch

Great! Now the branch is really deleted.

But when I run

git branch -a

I still get:

remotes/origin/coolbranch

Something to notice, is that when I clone a new repository, everything is fine and git branch -a doesn't show the branch.

I want to know - is there a way to delete the branch from the branch -a list without cloning a new instance?

Edit
Report

2 Answers

433

Try:

git remote prune origin

From the Git remote documentation:

prune

Deletes all stale remote-tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>".

With --dry-run option, report what branches will be pruned, but do not actually prune them.

answered 2011-02-23T17:29:14.923
298

Don't forget the awesome

git fetch -p

which fetches and prunes all origins.

answered 2012-08-30T12:55:22.250

Your Answer