Last active
April 22, 2025 10:59
-
-
Save glektarssza/68a638b143ddf7702e18b7fd014d0959 to your computer and use it in GitHub Desktop.
Git Prune Branches (w/ alias version)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
prune-branches = "!f() { git fetch --prune && 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 $([[ $@ =~ --force ]] && echo \"-D\" || echo \"-d\") $BRANCH; done };f" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f() { | |
git fetch --prune && 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 $([[ $@ =~ --force ]] && echo \"-D\" || echo \"-d\") $BRANCH; | |
done | |
} | |
f $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment