Created
November 6, 2016 10:31
-
-
Save mariok/79477e6162ef5ea8809751767f4056ce to your computer and use it in GitHub Desktop.
Helper-script for Git, which deletes all "dev_*" branches from a remote-repository, which have already been merged into branch "master"
This file contains hidden or 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 | |
| # Helper-script for Git | |
| # Deletes all branches from a remote-repository, which have already been merged into branch "master" | |
| # only branches starting with prefix "dev_" will be deleted | |
| # | |
| # based on https://gist.github.com/schacon/942899 | |
| # fetch the latest state from the remote repo, removing all remotely deleted branches locally as well | |
| git fetch -p | |
| # display the list of branches, which will be deleted | |
| git branch -r --merged origin/master | grep origin/dev_ | awk '{sub(/origin\//,"");print}' | |
| # delete the branches from the remote-repository | |
| git branch -r --merged origin/master | grep origin/dev_ | awk '{sub(/origin\//,"");print}' | xargs git push origin --delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment