Skip to content

Instantly share code, notes, and snippets.

@hanbei
Last active January 4, 2017 13:02
Show Gist options
  • Save hanbei/53ef046f827cfede81eb to your computer and use it in GitHub Desktop.
Save hanbei/53ef046f827cfede81eb to your computer and use it in GitHub Desktop.
Prune local branches
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
# fetch all repos
find . -maxdepth 1 -type d -exec echo {} \; -exec git --git-dir={}/.git --work-tree=$PWD/{} fetch \;
# prune all repos
find . -maxdepth 1 -type d -exec echo {} \; -exec git --git-dir={}/.git --work-tree=$PWD/{} remote prune origin \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment