Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mlaily
Last active July 13, 2016 09: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 mlaily/f2c0a4b3f144e1c2818447550d7166ae to your computer and use it in GitHub Desktop.
Save mlaily/f2c0a4b3f144e1c2818447550d7166ae to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Comparing current with remote:"
echo
git fetch --dry-run --prune
echo
read -p "Press enter to fetch the changes and prune the deleted branches..."
echo
git fetch --prune
echo
echo "The following locale branches are merged in origin/master and will be deleted:"
branches=$(git branch --merged origin/master | egrep -v "^\*?\s+master$" | sed -r 's/\*\s+//')
echo "$branches"
read -p "Press enter to continue or Ctrl+C to abort..."
echo
echo "$branches" | xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment