CIA git tips
The CIA’s engineering team kept an internal Confluence wiki (“Add your best Git tricks here! Share the love!”) — it leaked in the 2017 WikiLeaks Vault 7 publication, and the git tips page is immortal: mundane, practical, and identical to what every team’s wiki accumulates. Full verbatim capture (recovered off-host — the wiki macros don’t render for direct fetchers): clippings/wikileaks-org-ciav7p1-cms-page-1179773-html.md.
The tips that stuck
- Branch cleanup one-liner —
git branch --merged | grep -v "\*\|master" | xargs -n 1 git branch -d: delete every already-merged local branch, safely (-drefuses unmerged). Lived in spencer.wtf’s~/.zshrcsince he found the page (capture:clippings/spencer-wtf-2026-02-20-cleaning-up-merged-git-branches-a-one-liner-from-the-cias-leaked-dev-docs-html.md) — the variant withorigin/master+developin the grep guard is on the page itself. - Split a subdirectory into a new repo —
git filter-branch --prune-empty --subdirectory-filter plugins/mylib mylibafter cloning + branching, then push to the new remote. (Modern replacement:git filter-repo— filter-branch is deprecated and warns, but the page’s recipe is the ancestor.) - ours/theirs aliases —
ours = "!f() { git checkout --ours $@ && git add $@; }; f"— take a conflicted file wholesale from one side during a merge; the shell-function hack exists just to make$@behave. - alias-listing alias —
git config --get-regexp 'alias.*'piped through colrm/sed — for when you can’t remember the alias you set. - The rest:
commit --amend -C HEADvs-m,reset --soft HEAD^vs--hard,git stash branch(stash + new branch + re-stage in one move), fullbisect start/bad/good/run/resetwalkthrough, andGIT_SSL_NO_VERIFYfor self-signed remotes.
Where it fits
- The stash/reset/amend/bisect tricks are the same toolkit as Git recovery (ORIG_HEAD, rerere) and the Git Legit set (Git commit messages) — vault7 is the 2015-ish ancestor of all of them.
- The bisect walkthrough pairs with regression-test-first bisecting (
clippings/dev-to-paulinevos-fix-bugs-fast-with-regression-tests-and-auto-bisect-3khh.md). - Filter-branch/subdirectory-split is repo surgery — kin to monorepo extraction, the one genuinely structural tip on the page.
Related: Git recovery · Git commit messages · Git housekeeping · Git hooks · Diff tools