git: Delete All Branches but Master
Maintenance is incredibly important in any project, but if you want to take your professionalism to the next level, you should keep your git environment in shape. Unfortunately I'm not that guy -- I leave git branches laying around, even after they've been merged into master
. GitHub even provides a button to do the cleanup but I can't be bothered. Not good.
When you're ready to do some real cleanup on a repository, throw this at it:
git branch | grep -v "master" | sed 's/^[ *]*//' | sed 's/^/git branch -d /' | bash
The shell command above deletes every branch in your local checkout except for master
branch. This is a dangerous script but you could always check out a given branch from a remote like GitHub if you happen to need it!
If you follow me on Twitter, you know that I've been working on a super top secret mobile application using Appcelerator Titanium. The experience has been great: using JavaScript to create easy to write, easy to test, native mobile apps has been fun. My...
One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?
Every once in a while I come across a plugin that blows me out of the water and the most recent culprit is PassShark: a MooTools plugin that duplicates the iPhone's method of showing/hiding the last character in a password field. This gem of...
I've always been intrigued by recognition software because I cannot imagine the logic that goes into all of the algorithms. Whether it's voice, face, or other types of detection, people look and sound so different, pictures are shot differently, and from different angles, I...
The script becomes less dangerous, when it uses the
variant instead of the upper case
-D
. Then branches are only deleted, when they are already merged in any of the remaining branches, and no work is lost. (Also, the error messages show you, which branches have work, that has not yet landed in master.)Updated my post! Thank you!
git remote prune origin -)
Thank you, this worked well for me. I first tried it with
-d
, which deleted some, and then decided to go for-D
, which did end up deleting everything butmaster
.