Trim Git Branches Locally and Remotely in One Command
Here's a handy GIT alias to trim off old branches, keeping your repos clean and tidy.
Add this alias to your git config. It's a bit complex, so you will need to do it by hand.
--global, edit ~/.gitconfig
--system, edit /etc/gitconfig
[alias]
trim=!sh -c '[ $# = 2 ] && git branch -d "$2" && git push "$1" :"$2" || echo "Usage: git trim <remote> <branch>" >&2 && exit 1' -
To use it, just specify the remote and the branch name:
$ git trim origin my-old-branch
This will delete my-old-branch
locally and attempt to delete it from the remote as well.
Written by Chris Albrecht
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Alias
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#