Last active
August 29, 2015 14:12
-
-
Save techtonik/b3f0d4b9a56dbacb3afc to your computer and use it in GitHub Desktop.
git: Remove local branches merged upstream
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
#!/usr/bin/env python | |
# Remove merged git branches. Cross-platform way to execute: | |
# | |
# git branch --merged | grep -v master | xargs git branch -d | |
# | |
# Requires gitapi - https://bitbucket.org/haard/gitapi | |
# License: Public Domain | |
import gitapi | |
repo = gitapi.Repo('.') | |
output = repo.git_command('branch', '--merged').strip() | |
for branch in output.split('\n'): | |
branch = branch.strip() | |
if branch.strip(' *') != 'master': | |
print(repo.git_command('branch', '-d', branch).strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment