A journal for sharing all things software development related
Clean up merged branches
Fri, 19 Jul 2019 08:53 UTC by garethbrown
$ git branch | grep -v "master" | xargs git branch -D
This deletes all but the master branch locally. With github, cleaning up branches on github.com is pretty easy, so no need to replicate for the server from commandline.
Ran this 2019/07/22 - Note that it may have deleted the remote version of my current bug fix branch, but I was able to just re-push my local. Probably best done when all merged in. It won't delete branches that have 'master' or 'dev' somewhere in the name.
git branch -r --merged | grep -v master | grep -v develop | sed 's/origin\///' | xargs -n 1 git push --delete origin
The information on this site is provided “AS IS” and without warranties of any kind either express or implied. To the fullest extent permissible pursuant to applicable laws, the author disclaims all warranties, express or implied, including, but not limited to, implied warranties of merchantability, non-infringement and suitability for a particular purpose.
Email garethbrown: email@example.com