Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Deleting merged branches with Git
#!/bin/bash
set -x
# Update the master branch.
git checkout master
git pull upstream master
# Synchronize the remote repository.
git push origin master
# Find all merged branches and delete them in the local and remote
# repositories.
for branch in `git branch --merged | grep -v '*' | tr -d ' '`
do
git branch -d $branch
git push origin :$branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment