Top
Best
New

Posted by spencerldixon 19 hours ago

I found a useful Git one liner buried in leaked CIA developer docs(spencer.wtf)
641 points | 219 commentspage 7
woodpanel 8 hours ago|
I’ve been doing just `git branch -d $(git branch)`, what am I missing?
rickknowlton 16 hours ago||
honestly my go to is kind of similar, but I prefer using --format vs. straight grep. just feels like the plumbing is cleaner out of the box:

    git branch --merged origin/main --format="%(refname:short)" \ | grep -vE "^(main|develop)$" \ | xargs -r git branch -d

that said... pretty hilarious a dev was just like "uhh yeah ciaclean..." curious what... other aliases they might have??
fragmede 11 hours ago||
I want to point out explicitly that .git config supports aliases, so in .gitconfig put an [alias] section, and in that you can put ciaclean = "!alias ciaclean='git branch --merged origin/main | grep -vE "^\s(*|main|develop)" | xargs -n 1 git branch -d'"

so then it's `git ciaclean` and not bare `ciaclean` which imo is cleaner.

locallost 13 hours ago||
I've used this for about 10 years now. Pretty sure it was a widespread way of doing it before any CIA leak.
Svoka 14 hours ago||
I work with GitHub, so this oneliner relly helps me out. It also doesn't rely on grep, since --format have all you need:

    git branch --format '%(if:equals=gone)%(upstream:track,nobracket)%(then)%(refname:short)%(end)' --omit-empty | xargs --verbose -r git branch -D
It deletes all the branches for which remotes were deleted. GitHub deletes branches after PR was merged. I alias it to delete-merged
devhouse 17 hours ago||
don't forget to fetch first
spectaclepiece 12 hours ago||
how is this a news item. LLMs figured this out for me two years ago
freecodyx 12 hours ago|
i once used ai to generate a command doing the exact same thing.

git branch -vv | grep ': gone\]' | awk '{print $1}' | xargs -n 1 git branch -D

More comments...