Skip to content

Instantly share code, notes, and snippets.

@paflopes
Last active November 2, 2017 03:57
Show Gist options
  • Select an option

  • Save paflopes/b53a9cbcc9765fbe57b17d45d0a15361 to your computer and use it in GitHub Desktop.

Select an option

Save paflopes/b53a9cbcc9765fbe57b17d45d0a15361 to your computer and use it in GitHub Desktop.
#!/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
#!/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
#!/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