Skip to content

Instantly share code, notes, and snippets.

@Avery2
Created March 19, 2024 18:01
Show Gist options
  • Save Avery2/c86e50669bf8596e2784c95fcffa4d89 to your computer and use it in GitHub Desktop.
Save Avery2/c86e50669bf8596e2784c95fcffa4d89 to your computer and use it in GitHub Desktop.

Delete local branches that don't have a branch active on the remote.

git fetch -p ; git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | 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