Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created December 30, 2013 18:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdeboard/8185743 to your computer and use it in GitHub Desktop.
Save mattdeboard/8185743 to your computer and use it in GitHub Desktop.
#!/bin/bash
# You can run this to make fetch automatically prune any time you pull or
# fetch.
#
# git config remote.origin.prune true
git fetch --prune
# Abort early if there are local changes
git checkout master || exit
git pull --ff-only origin master || exit
# Remove any local branches that have been merged
git branch --merged master | grep -v "\*" | xargs -n 1 git branch -d
echo "These remote branches have not been merged into origin/master"
git branch -r --no-merge origin/master
echo "These local branches have not been merged into origin/master"
git branch --no-merge origin/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment