dangling-commit
branch
experimental commit dropped from main, reachable only via reflog
Description
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 Contracts
- 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})
Tags
Branches
main Use it
import { spinUpScenario } from '@gfargo/git-scenarios'
const repo = await spinUpScenario('dangling-commit') npx git-scenarios create dangling-commit import { describeWithScenario } from '@gfargo/git-scenarios/jest'
describeWithScenario('dangling-commit', (getRepo) => {
it('should have the expected state', async () => {
const repo = getRepo()
// your assertions here
})
}) Commit graph
* dca4ab1 (HEAD -> main) feat: keep this
* 7520170 chore: initial