Skip to content

Instantly share code, notes, and snippets.

@vovkab
Last active January 2, 2016 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vovkab/8245972 to your computer and use it in GitHub Desktop.
Save vovkab/8245972 to your computer and use it in GitHub Desktop.
# Publish local branch to repo and make it tracking:
$ git push -u origin branch_name
# List remote branches:
$ git remote show origin
# Show stale branches that will be removed:
$ git remote prune origin --dry-run
# Delete stale branches:
$ git remote prune origin
Branches cleanup:
https://jira.atlassian.com/browse/BSERV-4142
# list merged branches
BRANCHES=`git branch -r --merged | grep -v "*" | grep -v master | grep -v develop | grep -v release/ | grep -v hotfix/ | sed 's/origin\///'`
printf "Removing branches: \n$BRANCHES"
# delete all remote branches merged into the current branch (i.e. develop), excluding release/master/develop branches
git branch -r --merged | grep -v "*" | grep -v master | grep -v develop | grep -v release/ | grep -v hotfix/ | sed 's/origin\///' | xargs -n 1 git push --delete origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment