Git Advanced — Trivia & Interesting Facts¶
Surprising, historical, and little-known facts about Git internals, recovery, safety techniques, and famous saves.
Pixar almost lost Toy Story 2 due to a bad rm -rf command¶
In 1998, someone accidentally ran rm -rf * on Pixar's main server, deleting 90% of Toy Story 2. Their backup system had failed months earlier without anyone noticing. The film was saved only because a technical director had a full copy on her home machine (she'd been working remotely after having a baby). This incident predates Git but perfectly illustrates why version control matters.
git reflog can recover from almost any Git disaster¶
The reflog keeps a 30-day record of every state change in your repository. Even after a disastrous git reset --hard, git rebase gone wrong, or accidental branch deletion, the old commits still exist and can be recovered via git reflog. The commits are only truly gone after garbage collection runs (default: 30 days for unreachable commits).
git stash was added because developers kept losing work¶
The git stash command was added to Git in version 1.5.3 (2007) after developers consistently lost uncommitted work when switching branches. Before stash, you had to either commit half-done work (polluting history) or manually save changes to files. Stash created a dedicated mechanism for temporarily shelving work.
git cherry-pick was named after the idiom, not the fruit¶
The git cherry-pick command — applying a single commit from one branch to another — is named after the English idiom "cherry-picking," meaning to selectively choose the best items. In Git's context, you're picking the one good commit from a branch without taking everything else.
Force-pushing to main has destroyed production deployments¶
There are numerous documented cases of git push --force to the main branch causing production outages. In CI/CD systems that deploy from main, a force push that rewrites history can trigger deployments of old or incomplete code. Many organizations now protect main with branch protection rules specifically to prevent force pushes.
The .gitignore file has prevented thousands of credential leaks¶
The .gitignore file, which tells Git to exclude files from tracking, has prevented countless accidental commits of .env files, API keys, and private keys. Despite this, GitGuardian reports that over 10 million secrets are leaked in public Git repositories each year. The .gitignore only works if it's configured before the sensitive file is committed.
git blame was almost called git praise¶
Some Git users find git blame — which shows who last modified each line of a file — to have an unfairly negative connotation. The command is primarily used to understand context, not assign blame. Some organizations alias it to git praise or git annotate (which is a built-in alias). The original name stuck because Linus Torvalds has a sharp sense of humor.
Signed commits can prove code wasn't tampered with¶
GPG-signed Git commits provide cryptographic proof that a commit was created by a specific person and hasn't been modified. After the 2020 SolarWinds supply chain attack, signed commits gained renewed attention. However, fewer than 5% of commits on public repositories are signed, and many organizations still don't require signing.
git fsck can find corruption that git status misses¶
The git fsck (file system check) command validates the integrity of all objects in a Git repository. It can detect corrupted objects, dangling commits, and broken references that git status wouldn't report. Running it periodically is recommended but rarely done — most developers only discover it when their repository is already corrupted.
The biggest Git recovery story involves the entire Linux kernel¶
In 2020, a kernel developer accidentally pushed a commit that broke the build for multiple architectures. Because the Linux kernel uses a strictly controlled merge process (Linus Torvalds reviews and merges everything), the broken commit was identified via git bisect, reverted within hours, and the kernel's integrity was maintained. The process worked exactly as Linus designed it 15 years earlier.