Last active
July 8, 2017 02:50
-
-
Save dflima/c5137785c437fcdf0c74a544bfc290fc to your computer and use it in GitHub Desktop.
Deletes branches merged with <branch>
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 | |
function usage() | |
{ | |
printf "Usage:\n\n" | |
printf "./delete_merged_branches <branch>\n\n" | |
} | |
if [ "$1" == "" ]; then | |
usage | |
exit 0 | |
fi | |
in_branch="$(git branch | grep \* | cut -d ' ' -f2)" | |
out_branch=$1 | |
git checkout $out_branch; | |
git pull; | |
git branch --merged | grep -v $out_branch | xargs git branch -D; | |
git checkout $in_branch; |
Ignore this (is http://stevenharman.net/git-clean-delete-already-merged-branches version?), use this: https://gist.github.com/schacon/942899
For clean projects using /feature or /fix.
$ git fetch --prune;
$ git branch --remote --merged |
grep origin |
grep -v '>' |
grep -v master |
grep -v develop |
xargs -L1 |
cut -d"/" -f2- |
xargs git push origin --delete;
@caiotava nice approach, thanks!
@webysther that's a nice feature, but I don't want to delete remote branches. Maybe I can include that as an option. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dflima, add a git pull