Last Updated: February 25, 2016
·
2.213K
· nicolaslazartekaqui

Git - Cleaning old branches with prune

Assuming the project has many branches

$ git branch -a

* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/other-branch

when in remote a branch is removed, your project keep this branch in a history of remote branches

$ git push --delete origin other-branch

$ git branch -a

* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/other-branch

to clean up the old branches of your listing, you can do

$ git remote prune origin

* master
remotes/origin/HEAD -> origin/master
remotes/origin/master