Skip to content

Instantly share code, notes, and snippets.

@jmsfwk
Created June 6, 2019 13:46
Show Gist options
  • Save jmsfwk/35622dfc2113e5cd74813027af0a4e35 to your computer and use it in GitHub Desktop.
Save jmsfwk/35622dfc2113e5cd74813027af0a4e35 to your computer and use it in GitHub Desktop.
Git delete merged branches
#!/bin/bash
set -ue
git fetch
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
#!/bin/bash
set -ue
git fetch
git branch --remote --merged origin/master | egrep -v "(^\*|master|dev)" | cut -d"/" -f2- | xargs git push origin -d
@jmsfwk
Copy link
Author

jmsfwk commented Jun 6, 2019

If you put these somewhere on you path and make them executable you can run them with git cleanup and git cleanup-remote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment