Journal: Software Development

Email: mail@appsoftware.com

Software development notes and articles

A journal for sharing all things software development related


Clean up merged branches

Fri, 19 Jul 2019 08:53 UTC

Source:

https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged?page=1&tab=oldest#tab-top

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.