5 ms·
We all have something similar, it seems! I stole mine from https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote#comment91928
by Cherub0774 7mo ago
We all have something similar, it seems! I stole mine from https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote#comment91928557_38404202 https://stackoverflow.com/questions/7726949/remove-tracking-....
I also set mine up to run on `git checkout master` so that I don't really have to think about it too hard -- it just runs automagically. `gcm` has now become muscle memory for me.
alias gcm=$'git checkout master || git checkout main && git pull && git remote prune origin && git branch -vv | grep \': gone]\'| grep -v "\*" | awk \'{ print $1; }\' | xargs -r git branch -D'
- masklinn 7mo agoSame using a git alias rather than shell, and without the network bits, it just cleans up branches which have an upstream that has been deleted: '!f() { git branch --format '%(refname:short) %(upstream:track,nobracket)' | awk '$2~/^gone$/{print $1}' | xargs git branch -D; }; f'