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!
Your early CSS books were instrumental in pushing my love for front end technologies. What was it about CSS that you fell in love with and drove you to write about it?
At first blush, it was the simplicity of it as compared to the table-and-spacer...
Before we get started, it's worth me spending a brief moment introducing myself to you. My name is Mark (or @integralist if Twitter happens to be your communication tool of choice) and I currently work for BBC News in London England as a principal engineer/tech...
I love progress bars. It's important that I know roughly what percentage of a task is complete. I've created a highly customizable MooTools progress bar class that animates to the desired percentage.
The Moo-Generated XHTML
This DIV structure is extremely simple and can be controlled...
A while back I shared a clever technique for creating triangles with only CSS. Over the past year, I've found CSS triangles incredibly effective, especially when looking to create tooltips or design elements with a likewise pointer pattern. There's another common shape...
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
.