Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete "remote" branch that still shows locally?

Tags:

git

git-branch

A branch was created unintentionally. I want to delete it. In fact, I thought I deleted it last week, and it doesn't show up in searches on bitbucket, so I'm inclined to think the problem is just in my local repo. Why does the branch still show up in my local repo after doing this?

$ git branch -d ebc_193_157_154_order_creation_xsd_validation_and_refactored_code
error: branch 'ebc_193_157_154_order_creation_xsd_validation_and_refactored_code' not found.
$ git push bitbucket :ebc_193_157_154_order_creation_xsd_validation_and_refactored_code
error: unable to delete 'ebc_193_157_154_order_creation_xsd_validation_and_refactored_code': remote ref does not exist
error: failed to push some refs to 'bitbucket.org:trueaction/eb2c'

And still it remains:

$ git branch -r | grep ebc_193
  bitbucket/ebc_193_157_154_order_creation_xsd_validation_and_refactored_code
$ git branch -a | grep ebc_193
  remotes/bitbucket/ebc_193_157_154_order_creation_xsd_validation_and_refactored_code

What must I do to be rid of it?

like image 485
kojiro Avatar asked Oct 28 '13 13:10

kojiro


1 Answers

You are looking for git remote prune which removes stale remote branches.

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

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

In your situation, you'll want to use git remote prune origin.

like image 194
Benjamin Bannier Avatar answered Sep 19 '22 14:09

Benjamin Bannier