Created
July 18, 2012 23:45
-
-
Save jkakar/3139743 to your computer and use it in GitHub Desktop.
Deleting merged branches with Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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