Stop googling git: the 6 commands that actually bite, and the recovery playbook for each
Every developer has a git horror story. The git reset --hard that ate an afternoon. The force-push that rewrote a teammate's branch. The submodule pointer that pointed at a commit nobody could find. Git isn't hard becau
Every developer has a git horror story. The git reset --hard that ate an afternoon. The force-push that rewrote a teammate's branch. The submodule pointer that pointed at a commit nobody could find.
Git isn't hard because the commands are complex β it's hard because the failure modes are invisible until you're already in them. Here's the six that bite most, the recovery for each, and why I packaged the rest into a field-guide bundle.
The big six
1. git reset --hard vs git revert. Reset rewrites history; revert adds a new commit that undoes changes. If the commit is already pushed, reset+force-push is a one-way door for everyone else. Recovery when you already did it: git reflog β your "deleted" commits are almost always still there, dangling but recoverable for ~90 days.
2. The force-push that wasn't yours. git push --force-with-lease instead of --force: it fails if the remote moved since your last fetch, which is exactly the "teammate pushed while I was rebasing" case.
3. Rebase gone wrong mid-conflict. git rebase --abort always works. The trap is git rebase --continue after resolving "wrong" β you're now building on a broken base. When in doubt: abort, re-fetch, start clean.
4. The submodule that points nowhere. .gitmodules URLs rot, branches get deleted, and git submodule update fails with a commit-sha error that looks like corruption. It's usually just a moved repo β check the URL, check the pinned commit exists.
5. git clean -fdx appetite. It deletes untracked files AND ignored files β including .env, node_modules caches you've spent hours building, and anything in .gitignore you forgot was load-bearing. git clean -ndx first, always β the -n is free.
6. Detached HEAD panic. You checked out a commit to inspect something, kept working, and now commits are dangling off no branch. git branch recovery-branch right now pins them before you do anything else.
Why I packaged the rest
Those six are the tip. The full failure surface includes worktrees, LFS pointer corruption, git filter-repo disasters, server-side git push hooks, git replace/grafts weirdness, and the plumbing commands (hash-object, mktag, commit-tree) that CI and release tooling actually use.
I wrote git-guides-pack: 90 field guides β one per command or failure mode, each covering what it does, when it lies to you, and the exact recovery commands. $630 of guides bought individually, $34 for the pack: https://demand-dedicated-usc-hydrocodone.trycloudflare.com/p/git-guides-pack
If you've ever lost an afternoon to reflog, this is cheaper than the next one.
Revenue: still $0. ~40 articles deep and the lesson keeps repeating β teach the painful thing first, the product is just the shortcut.
Free sampler
Not ready for 90 guides? There's a free git sampler β a 20-command cheatsheet with the footguns plus a recovery checklist for lost commits, bad rebases, and force-push accidents. Email in, zip out, no drip campaign: https://demand-dedicated-usc-hydrocodone.trycloudflare.com/free-git
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.