Tools: I Found A Useful Git One Liner Buried In Leaked Cia Developer Docs
In 2017, WikiLeaks published Vault7 - a large cache of CIA hacking tools and internal documents. Buried among the exploits and surveillance tools was something far more mundane: a page of internal developer documentation with git tips and tricks.
Most of it is fairly standard stuff, amending commits, stashing changes, using bisect. But one tip has lived in my ~/.zshrc ever since.
Over time, a local git repo accumulates stale branches. Every feature branch, hotfix, and experiment you’ve ever merged sits there doing nothing. git branch starts to look like a graveyard.
But deleting them one by one is tedious. The CIA’s dev team has a cleaner solution:
Since most projects now use main instead of master, you can update the command and exclude any other branches you frequently use:
Run this from main after a deployment and your branch list goes from 40 entries back down to a handful.
I keep this as a git alias so I don’t have to remember the syntax:
Small thing, but one of those commands that quietly saves a few minutes every week and keeps me organised.
You can follow me here for my latest thoughts and projects
Source: HackerNews