From e6ea385b333c329b6fb6da89ee31019b6cbd1a1c Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Sun, 28 Apr 2024 12:11:46 -0400 Subject: [PATCH] add filtering for older branches to git gone Signed-off-by: ahuston-0 --- users/alice/home/git.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/users/alice/home/git.nix b/users/alice/home/git.nix index f0e83f4..661b2a8 100644 --- a/users/alice/home/git.nix +++ b/users/alice/home/git.nix @@ -19,6 +19,11 @@ !git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | # dump all branches awk '$2 == "[gone]" {print $1}' | # get nuked branches sed 's/\\x27/\\x5C\\x27/' | # remove single quotes, for xargs reasons + xargs -r git branch -D; # nuke the branches + git for-each-ref --format '%(refname:short) %(upstream)' | # dump all older branches + awk 'NF < 2 {print $1}' | # get nuked branches + grep -Pv "(^origin/|^origin$|stash)" | # filter out remotes & stash + sed 's/\\x27/\\x5C\\x27/' | # remove single quotes, for xargs reasons xargs -r git branch -D # nuke the branches ''; };