Skip to content

Instantly share code, notes, and snippets.

Created July 18, 2012 23:45
What would you like to do?
Deleting merged branches with Git
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 ' '`
git branch -d $branch
git push origin :$branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment