Skip to content

Instantly share code, notes, and snippets.

@jeromy-vandusen-obs
Last active February 5, 2021 16:57
Show Gist options
  • Save jeromy-vandusen-obs/daf932f530112123bedc29f95d162beb to your computer and use it in GitHub Desktop.
Save jeromy-vandusen-obs/daf932f530112123bedc29f95d162beb to your computer and use it in GitHub Desktop.
Helpful Git Aliases

Helpful Git Aliases

Git Gone

Description

This will remove all deleted remote branches and remove local branches that are tracking a deleted remote branch. This is borrowed from here.

Setup

$ git config --global alias.gone "! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '\$2 == \"[gone]\" {print \$1}' | xargs -r git branch -D"

Usage

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