Skip to content

Instantly share code, notes, and snippets.

@matejskubic
Created May 28, 2026 08:20
Show Gist options
  • Select an option

  • Save matejskubic/2daa3e9fb6937e2a114fe0ee10cbf246 to your computer and use it in GitHub Desktop.

Select an option

Save matejskubic/2daa3e9fb6937e2a114fe0ee10cbf246 to your computer and use it in GitHub Desktop.
git: delete obsolete local branches
git fetch --prune; git for-each-ref --format="%(refname:short) %(upstream:track)" refs/heads | ? { $_ -match "\[gone\]" } | % { git branch -d (($_ -split " ")[0]) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment