Skip to content

Instantly share code, notes, and snippets.

@onion2k
Created September 16, 2019 09:49
Show Gist options
  • Save onion2k/0730c2b01e08551e37843426ae7558c8 to your computer and use it in GitHub Desktop.
Save onion2k/0730c2b01e08551e37843426ae7558c8 to your computer and use it in GitHub Desktop.
Prune local git branches

#Delete all local branches that aren't on remote.

##safe

git branch -vv | grep 'origin/.\*: gone]' | awk '{print \$1}' | xargs git branch -d

##unsafe - force delete

git branch -vv | grep 'origin/.\*: gone]' | awk '{print \$1}' | xargs git branch -D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment