Skip to content

Instantly share code, notes, and snippets.

@jkakar
Created July 18, 2012 23:45
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 jkakar/3139743 to your computer and use it in GitHub Desktop.
Save jkakar/3139743 to your computer and use it in GitHub Desktop.
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