Skip to content

Instantly share code, notes, and snippets.

@jiang-wei
Created June 5, 2018 14:13
Show Gist options
  • Save jiang-wei/2c088b29c03423aa097dccf5a2870e4d to your computer and use it in GitHub Desktop.
Save jiang-wei/2c088b29c03423aa097dccf5a2870e4d to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://ben.lobaugh.net/blog/201616/cleanup-and-remove-all-merged-local-and-remote-git-branches
for remote in `git branch -r `; do git branch --track $remote; done
git branch --merged master | grep -v master | cut -d/ -f2- | xargs -n 1 git push --delete origin
git branch --merged master | grep -v master | xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment