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!
Firefox OS is all over the tech news and for good reason: Mozilla's finally given web developers the platform that they need to create apps the way they've been creating them for years -- with CSS, HTML, and JavaScript. Firefox OS has been rapidly improving...
One of my favorite social APIs was the Open Graph API adopted by Facebook. Adding just a few META tags to each page allowed links to my article to be styled and presented the way I wanted them to, giving me a bit of control...
One excellent way to add dynamism to any website is to implement a slideshow featuring images or sliding content. Of course there are numerous slideshow plugins available but many of them can be overkill if you want to do simple slideshow without controls or events.
With Firefox OS, asm.js, and the push for browser performance improvements, canvas and WebGL technologies are opening a world of possibilities. I featured 9 Mind-Blowing Canvas Demos and then took it up a level with 9 Mind-Blowing WebGL Demos, but I want to outdo...
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
.