Skip to content

Instantly share code, notes, and snippets.

@vilmosioo
Created June 9, 2014 09:00
Show Gist options
  • Save vilmosioo/f8e36e6236327263bfd2 to your computer and use it in GitHub Desktop.
Save vilmosioo/f8e36e6236327263bfd2 to your computer and use it in GitHub Desktop.
List of commits to handle local and remote branches
// create local branches that target remote branches
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
// delete all remote branches that have been merged to master
git branch --merged master | grep -v master | xargs -n 1 git push --delete origin
// delete all local branches that have been merged to master
git branch --merged master | grep -v master | xargs git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment