Skip to content

Instantly share code, notes, and snippets.

@locriani
Last active May 23, 2017 16:58
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 locriani/f24890a03ea20e83044c to your computer and use it in GitHub Desktop.
Save locriani/f24890a03ea20e83044c to your computer and use it in GitHub Desktop.
git remote prune origin
git fetch -p origin
git branch --merged |
grep -v \"\*\" |
grep -v master |
xargs -n 1 git branch -d
git remote prune origin
git branch -r --merged origin/master |
grep origin |
grep -v '>' |
grep -v master |
grep -v preproduction |
grep -v production |
grep -v dev |
grep -v qa |
xargs -L1 |
awk '{sub(/origin\//,"");print "- "$0}' |
tee .goodbye |
cat
cat .goodbye |
xargs -L1 |
awk '{sub(/\- /,"");print $0}' |
xargs git push origin --delete
rm .goodbye
@locriani
Copy link
Author

alias gp='~/.bash/gitprunelocal.sh'
alias gpr='~/.bash/gitpruneremote.sh'
alias gprd='~/.bash/gitpruneremotedestructive.sh'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment