Skip to content

Instantly share code, notes, and snippets.

View copyleftdev's full-sized avatar

Don Johnson copyleftdev

View GitHub Profile
@copyleftdev
copyleftdev / git-blame-copy.sh
Created May 25, 2026 20:21
git blame -C — follow code that moved between files
# git blame -C — follow moved code across files
# Standard blame breaks when code moves. -C detects copies.
# Without copy detection — everything attributed to the refactor commit:
git blame src/freq.py
# With copy detection — attribution follows the original author:
git blame -C -C -C src/freq.py
# Three -C flags:
@copyleftdev
copyleftdev / git-fixup-autosquash.sh
Created May 25, 2026 20:21
git commit --fixup and git rebase --autosquash
# git commit --fixup + git rebase --autosquash
# Fix any past commit cleanly — no painful interactive rebase editing.
# Spot a typo in the third commit back:
git add the-fix.rs
git commit --fixup HEAD~2
# creates: "fixup! <original commit message>"
# Let autosquash reorder + squash automatically:
git rebase -i --autosquash main
@copyleftdev
copyleftdev / git-sparse-checkout.sh
Created May 25, 2026 20:20
git sparse-checkout — materialize only the paths you need
# git sparse-checkout — check out only what you need
# Monorepo with 40 packages? Only materialize the two you work in.
git sparse-checkout init --cone
git sparse-checkout set packages/auth packages/api
# Everything else vanishes from disk — still in history, just not on disk.
# Add more paths any time:
git sparse-checkout add tests
@copyleftdev
copyleftdev / git-range-diff.sh
Created May 25, 2026 20:20
git range-diff — compare two sequences of commits patch by patch
# git range-diff — diff of diffs
# Verify a rebase didn't silently mangle any patches.
# Compare two parallel sequences of commits from a common base:
git range-diff main@{1} main feature-branch
# Output per commit pair:
# 1: <sha1> = 1: <sha2> feat: add auth
# 2: <sha1> ! 2: <sha2> feat: add routes ← ! means patches differ
#
@copyleftdev
copyleftdev / git-notes.sh
Created May 25, 2026 20:20
git notes — annotate commits without touching their SHA
# git notes — attach metadata to commits without rewriting history
# Notes live in refs/notes/commits — the commit SHA never changes.
git notes add -m "Deployed to prod at 14:32 UTC, PLAT-482" HEAD
git notes show HEAD
# See notes inline in git log:
git log --show-notes --oneline -10
@copyleftdev
copyleftdev / git-pickaxe.sh
Created May 25, 2026 20:20
git log -S — the pickaxe: find when a string was added or removed
# git log -S — the pickaxe
# Find commits where a specific string's count in a file changed.
# Searches diff content, not commit messages.
# When was this secret added or removed?
git log -S "API_SECRET" --all --oneline
# See the full diff for each match:
git log -S "API_SECRET" -p
@copyleftdev
copyleftdev / git-rerere.sh
Created May 25, 2026 20:20
git rerere — reuse recorded conflict resolutions
# git rerere — never resolve the same conflict twice
# Enable once globally, then forget it's there.
git config --global rerere.enabled true
# First time you hit a conflict:
# resolve it manually, then:
git add src/the-file.py
git commit -m "merge: resolved"
# rerere silently records the resolution fingerprint
@copyleftdev
copyleftdev / git-bisect.sh
Created May 25, 2026 20:20
git bisect run — automated binary search for a regression
# git bisect — binary search your blame
# Manual mode: you tell git good/bad at each step.
git bisect start
git bisect bad # current commit is broken
git bisect good v2.3.0 # this tag was clean
# git checks out the midpoint — test, then:
git bisect good # or: git bisect bad
# repeat ~7 times until git prints the culprit
@copyleftdev
copyleftdev / git-worktree.sh
Created May 25, 2026 20:20
git worktree — multiple checkouts, one repo
# git worktree — multiple checkouts, one repo
# Run two branches side-by-side without stashing or switching.
git worktree add ../feature-branch feature/my-feature
git worktree add ../hotfix-branch main
# Both share the same .git — no second clone needed.
# List all active worktrees:
git worktree list
@copyleftdev
copyleftdev / CLAUDE.md
Created April 12, 2026 02:36
Palimpsest: CLAUDE.md (Full Project Instructions)

PALIMPSEST — Deterministic Crawl Kernel

Same input + same seed = identical crawl, identical artifacts, identical replay. Everything bends around this. If we lose this, we've built noise — not history.

What This Is

A crawl kernel, not a crawler. Provides deterministic scheduling, reproducible fetch execution, verifiable artifact generation, replay-grade normalization, and temporal indexing as a first-class primitive. CLI, UI, dashboards are thin skin. The kernel is the product.