Skip to content

Instantly share code, notes, and snippets.

@chrisweight
Last active February 13, 2026 09:59
Show Gist options
  • Select an option

  • Save chrisweight/1d72f519f246491b9e3bf9fd4d5e6b1a to your computer and use it in GitHub Desktop.

Select an option

Save chrisweight/1d72f519f246491b9e3bf9fd4d5e6b1a to your computer and use it in GitHub Desktop.
Delete local branches if remote no longer exists

git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D

--

As a ZSH function:

function gfd() {
    git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment