Batch delete all local Git branches

If you’re tired of having tons of local branches and need a quick way to batch delete all local unused git branches, then this is for you.

Make sure you switch to develop or master before running this:

git branch --merged | grep -v \* | xargs git branch -D 

Once run, your local branches will look a lot cleaner and you should see a summary of the deleted local branches like so:

Deleted branch 403canonical (was 8f34dcbfef).
Deleted branch refactor (was 80b4b6f9d0).
Deleted branch adjust (was 0621a85c71).
Deleted branch QCT-153 (was 5d7f67240c).
Deleted branch bug/forms (was c5be3892f8).
Deleted branch enable-minify (was 48357f0583e).
Deleted branch images/improve (was 48bc63a9ca).
Deleted branch image/increase (was 6fd4126a78).
Deleted branch image/optimization (was f2bd2a9331).
Deleted branch image/optimization (was fdfd409582).
Deleted branch image/tweaks (was 13555da609).
Deleted branch jobs-fix (was cf92f7759b).
Deleted branch jsalter (was 7db8446f0c).
Deleted branch menu/detectionfix (was 998721ed92).
Deleted branch pagealias (was 5ca729a480).
Deleted branch path-update (was 73415d677d).
Deleted branch phpmailer (was 08c62cd6ee).
Deleted branch prod-fixes (was 5f3bab0220).
Deleted branch robotstxt (was 7d7e669375).
Deleted branch update/articles (was f14acbd8c6).
Deleted branch sitemap-fix (was a0e63485f8).
Deleted branch various-fixes-20 (was e87cf28406).