If you’ve been working on a repo for awhile, you’ve probably accumulated a fair amount of local branches that no longer exist on the remote (e.g., github). You’ll want to occasionally clean those up; fortunately git has a command for that: git prune.
Here’s how:
Open a command window and navigate to your working folder. Get a list of all stale branches that no longer exist on the remote by doing a dry run:
git remote prune origin --dry-run
If that list looks good (hint: it should unless you really like keeping branches around), go ahead and prune them:
git remote prune origin
Note that this will only delete branches that have been merged so any unmerged branches or those never pushed will not be deleted.
Our website uses cookies from third party services to improve your browsing experience. Read more about this and how you can control cookies by clicking "Privacy Preferences".