Deleting Only Removes the Pointer
git branch -D feature/spice-blends
This removes one small real file — the branch pointer. The four real commits it named are still sitting in the object database, genuinely untouched.
Finding Its Real Last Position
git reflog | grep -A1 "moving from feature/spice-blends to master"
The checkout line itself shows the destination's hash (master's), not the deleted branch's — the entry one step further back, the real last commit made on that branch, is the one that actually matters here.
Bringing It Back
git branch recovered-spice-blends <hash>
git log --oneline recovered-spice-blends -4
A real, ordinary branch pointer, recreated at the exact right commit — all four real commits, back in full.
Before another repair, review how reflog records local movements. If the branch was moved by a reset instead of deleted, follow recovering from git reset --hard.
feature/spice-blends has four real, genuine commits — never merged into master. git branch -D force-deletes it anyway, the way a real "I don't need this anymore" click sometimes turns out to be a mistake.
Deleting a branch only ever removes the real pointer — a small file naming a commit hash. The four real commits themselves are untouched, sitting in the real object database exactly as before, simply unreachable from any current ref. HEAD's own reflog remembers switching away from that branch, which is exactly enough to find its way back.
git branch <name> <hash>
Creates a real, ordinary branch pointer at a specific commit — exactly the same operation as creating any new branch, just aimed at a hash recovered from reflog instead of the current HEAD. Confirmed directly in this lab: the recreated branch's real history is byte-identical to the deleted one.
Takeaways
- git branch -D only removes a branch's pointer file — the commits it named are untouched
- A "checkout: moving from X to Y" reflog line shows Y's hash, not X's — the branch's own real last commit is the entry one step further back
- git branch <name> <hash> recreates a real, ordinary branch at any commit, including one only findable via reflog
- This works as long as reflog has not expired and real garbage collection has not yet removed the objects