Skip to content

Instantly share code, notes, and snippets.

@organom
Created October 4, 2023 18:44
Show Gist options
  • Save organom/f2e137752fb83e28c8ea1e3659bfbfc5 to your computer and use it in GitHub Desktop.
Save organom/f2e137752fb83e28c8ea1e3659bfbfc5 to your computer and use it in GitHub Desktop.
Cleanup all git local branches that are not in remote
!#/bin/bash
function git-branch-cleanup() {
git remote prune origin
git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d
}
git-branch-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment