Last active
November 2, 2017 03:57
-
-
Save paflopes/b53a9cbcc9765fbe57b17d45d0a15361 to your computer and use it in GitHub Desktop.
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 | |
| # remove the branches remotely | |
| git branch --merged | egrep -v "(^\*|master|demo|preprod|production)" | xargs -n 1 git push --delete origin | |
| # remove the branches locally with | |
| # git branch --merged | egrep -v "(^\*|master|demo|preprod|production)" | xargs -n 1 git branch -d |
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 | |
| # clean local branches so we don't try to delete ghost branches on remote | |
| git branch --merged | egrep -v "(^\*|production|acceptance|dev)" | xargs -n 1 git branch -d | |
| git fetch origin | |
| for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v dev `; do | |
| git branch --track ${branch#remotes/origin/} $branch | |
| done | |
| # delete remote branches | |
| git branch --merged | egrep -v "(^\*|production|acceptance|dev)" | xargs -n 1 git push --delete origin | |
| # now delete one for all the local branches | |
| git branch --merged | egrep -v "(^\*|production|acceptance|dev)" | xargs -n 1 git branch -d |
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 | |
| for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do | |
| git branch --track ${branch#remotes/origin/} $branch | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment