Skip to content

Instantly share code, notes, and snippets.

@adrienjoly
Last active April 2, 2020 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrienjoly/351a9156c3a7e753b7dda44538953c1d to your computer and use it in GitHub Desktop.
Save adrienjoly/351a9156c3a7e753b7dda44538953c1d to your computer and use it in GitHub Desktop.
List local git branches that were squashed and merged to master
# List local branches that were squashed and merged to master
$ comm -1 -2 \
<(git remote prune origin --dry-run | sed "s/^.*origin\///g") \
<(git branch | sed "s/^..//") \
| sed "/^$/d"
# List local branches that were squashed and merged to master
# ... then give you the opportunity to edit them before deleting them.
$ comm -1 -2 \
<(git remote prune origin --dry-run | sed "s/^.*origin\///g") \
<(git branch | sed "s/^..//") \
| sed "/^$/d" \
>/tmp/merged-branches \
&& vi /tmp/merged-branches \
&& xargs git branch -d </tmp/merged-branches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment