Cleaning old branches

October 11, 2012 John Barker

We’re using Github pull requests on our project. Which means whenever a pull request is accepted, a branch is left lying around.

So I wrote a quick script to remove all remote branches that have been merged into develop (our working branch, you’ll have to alter the first instance of ‘develop’ to master if you use a more typical git branching model).

Here goes:

git branch -r --merged develop | sed 's/ *origin///' | grep -v 'master$' | grep -v HEAD | xargs -n 1 printf "echo git push origin :%sn" | bash

About the Author

Biography

More Content by John Barker
Previous
Using the New Scripted JavaScript Editor for Node.js Development
Using the New Scripted JavaScript Editor for Node.js Development

This week VMware released the Scripted code editor on GitHub: https://github.com/scripted-editor/scripted. ...

Next
Server Side Events?
Server Side Events?

Helps Any experience with HTML5 SSE? I want to try out HTML5's Server-Side-Events (http://www.igvita.com/2...

How do you measure digital transformation?

Take the Benchmark