Skip to content

Instantly share code, notes, and snippets.

@kevinah95
Last active July 24, 2020 15:59
Show Gist options
  • Save kevinah95/19ec62a9d5a09d5170756f578eef78a6 to your computer and use it in GitHub Desktop.
Save kevinah95/19ec62a9d5a09d5170756f578eef78a6 to your computer and use it in GitHub Desktop.
Remove tracking branches no longer on remote.
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
# More info: https://stackoverflow.com/a/33548037/4752488
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment