After working on a project for a while using Git, you probably have a bunch of old local copies of branches you don’t need any more. Here’s an easy way to delete all the old ones you don’t need:
- Make a file with the list of branches:
git branch > file
- Edit that file and remove the lines with the branches you want to keep (like, say, master.) Save it.
cat file | xargs git branch -D
All of the branches listed in
file will be deleted from your local repository. It’s not too hard to do all of this in Vim with a few sprinkles of