The postmortem blamed the wrong config
On 2026-08-17 I refreshed my lab repo’s off-box mirror with the exact command my notes called safe, and it deleted 13 of its 17 branches.
The mirror was a bare repo on my F: drive. It held branches that had only ever lived on Gitea, which was gone by then. The note next to the command said one thing:
git -C /mnt/f/.../homelab.git fetch ~/projects/Lab '+refs/heads/*:refs/heads/*'
Don’t add
--pruneto that.
I didn’t. It pruned anyway.
Getting them back
Deleting a ref doesn’t delete objects. No gc had run, so every tip was still in the pack. The catch is that bare repos keep no reflog by default, so there was nothing to undo with. The name-to-SHA map came out of a clone’s remote-tracking refs:
git for-each-ref refs/remotes/ # in a clone, to get each branch's SHA
git -C homelab.git update-ref refs/heads/<branch> <sha>
A branch that had been merged and deleted locally was the merge commit’s second parent, <merge>^2. All 17 came back and git fsck was clean.
What the write-up said, and what git 2.43 does
The write-up I committed that day said the mirror was cloned with --mirror, so its own config carried fetch.prune = true, and every fetch pruned whatever the flag said. The fix was set at the source: fetch.prune = false in that repo’s config, plus core.logAllRefUpdates = true so a bare-repo deletion could be undone next time.
While writing this up I tried to reproduce it on git 2.43, and the first half doesn’t hold. A --mirror clone gets this, and nothing about pruning:
remote.origin.fetch=+refs/*:refs/*
remote.origin.mirror=true
The fetch still deleted branches, though. Asking git where the setting came from:
$ git -C mirror.git config --show-origin --get-all fetch.prune
file:/home/ibrah5em/.gitconfig true
In the reproduction it was my global config. With GIT_CONFIG_GLOBAL=/dev/null the same fetch kept every branch. ~/.gitconfig was last written on May 14, three months before the incident, so the global setting was most likely there on the day.
I’d seen the global setting before. On 2026-11-04, refreshing the mirror again, git couldn’t read the mirror’s own config at first, so the global fetch.prune = true looked like the live one. (Git also complained of “dubious ownership” on the drive that day, fixed with -c safe.directory=<path>.) My notes from that day still credit the mirror’s local false as the protection. I didn’t go back and ask where the August true had come from.
The fix held for a different reason
A local fetch.prune = false beats the global one. With the local override, the same fetch kept every branch.
So the fix held, just not for the reason the write-up gave. And the global setting would have pruned any bare repo I fetched into that way, mirror or not.