Skip to content

Instantly share code, notes, and snippets.

@rushi
Created April 23, 2020 17:42
Show Gist options
  • Save rushi/09e744692c219c100c2e3b32c1a1fd71 to your computer and use it in GitHub Desktop.
Save rushi/09e744692c219c100c2e3b32c1a1fd71 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Do a git remote prune <remote_name>`. This will delete all stale remote-tracking branches under <remote_name>. These
# stale branches have already been removed from the remote repository referenced by <remote_name>, but are still locally
# available in remotes/<remote_name>
git remote | xargs -n 1 -t git remote prune
# Delete branches
# git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d
## List all XOL branches that been merged into master and delete those
git branch --merged master | grep XOL | xargs -t -n 1 git branch -d
## List all CS branches that been merged into master and delete those
git branch --merged master | grep CS | xargs -t -n 1 git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment