Skip to content

Instantly share code, notes, and snippets.

@cjonstrup
Created April 29, 2020 04:39
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 cjonstrup/6f62105ab8b7ba732ba2f9cf82392574 to your computer and use it in GitHub Desktop.
Save cjonstrup/6f62105ab8b7ba732ba2f9cf82392574 to your computer and use it in GitHub Desktop.
Delete local branches that are merged
#!/bin/bash
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
git checkout master && git pull --prune --all && git branch --merged | grep -vE "^\*|master" | xargs -r git branch -d
git checkout $CURRENT_BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment