Skip to content

dangling-commit

branch

experimental commit dropped from main, reachable only via reflog

A commit exists in the object store but is not reachable from any
branch or tag — only via `HEAD@{1}` in the reflog.

`main` has 2 commits; the third "experimental" commit was dropped
by a `git reset --hard HEAD~1`. The object is still present and
can be recovered with `git checkout HEAD@{1}` or by handing the
SHA to `git branch recover <sha>`.

Useful for testing:
  - reflog-browsing UIs
  - "recover lost commit" affordances
  - `git fsck --lost-found` integrations
  • main has 2 commits
  • worktree is clean
  • the experimental commit is not reachable from any branch
  • the experimental commit is recoverable via the reflog (HEAD@{1})
reflogrecoverydangling
main
import { spinUpScenario } from '@gfargo/git-scenarios'

const repo = await spinUpScenario('dangling-commit')
* dca4ab1 (HEAD -> main) feat: keep this
* 7520170 chore: initial

Back to Scenario Browser