Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.4k points)

Lets' 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:


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?

1 Answer

0 votes
by (27.5k points)

To remove all such stale branches. 

$ git remote prune origin

But in order to just remove that particular remote-tracking branch:

$ git branch -d -r origin/coolbranch

Browse Categories