Skip to content

Instantly share code, notes, and snippets.

@jacquesbh
Created June 8, 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 jacquesbh/4320cba644cf29a4217ede72065b1754 to your computer and use it in GitHub Desktop.
Save jacquesbh/4320cba644cf29a4217ede72065b1754 to your computer and use it in GitHub Desktop.
Clean the branches in git repository according to the remote
#!/bin/bash
# Usage: ./git_clean_branches.sh REPOSITORY_PATH
# Go to the directory
cd "$1"
# Delete branches, but keep develop, master and the current branch
git remote prune origin
git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | xargs -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment