Skip to content

Choosing a Scenario

Not sure which scenario to reach for? Start here. The guide walks you from “what does my tool need?” to a concrete scenario name in a few steps.

If you already know you want to browse the full catalogue interactively, jump straight to Browse & Filter →.

Step 1 — What git state does your tool need?

The catalogue is organised by kind. Each kind maps to a class of git state:

What state does your tool need to handle?
├── Branch shape / history
│ (feature branches, ahead/behind upstream, diverged, detached HEAD, orphan)
│ → kind: branch → See "Branch scenarios" below
├── Working tree / index
│ (staged files, unstaged changes, untracked files, multiple worktrees)
│ → kind: worktree → See "Worktree & stash scenarios" below
├── In-progress git operation
│ (merge conflict, rebase conflict, cherry-pick, revert, bisect)
│ → kind: operation → See "Operation scenarios" below
├── Commit history shape
│ (long logs, merge commits, tags, shallow clone, large repo)
│ → kind: history → See "History scenarios" below
├── Stashed changes
│ (stash list, stash with untracked)
│ → kind: stash → See "Worktree & stash scenarios" below
└── Submodules
(pinned submodule, out-of-date submodule)
→ kind: submodule → See "Submodule scenarios" below

Once you know the kind, use the goal table below to find the scenario name.

Step 2 — Match your goal to a scenario

Branch scenarios

GoalScenario
Minimal baseline with a feature branchfeature-branch-one-commit
Feature branch ready to PR (4 commits ahead, clean)feature-pr-ready
Multiple varied commits to navigate / filtermulti-commit-branch
Changelog / log / review smoke testtwo-commit-feature
Branch synced with its upstream (“up to date”)branch-tracking-upstream
Branch with unpushed commits (N ahead)branch-ahead-of-upstream
Branch that needs a pull (N behind, fast-forwardable)branch-behind-upstream
Branch that has diverged (ahead AND behind)branch-diverged
Fork workflow: origin + upstream, tracking bothmulti-remote-with-tracking
Five branches in five different upstream states at oncebranch-sync-showcase
HEAD detached (no branch)detached-head
Orphan branch with no shared historyorphan-branch
Commit in the reflog only (dropped from history)dangling-commit
Branch hard-reset, old tip recoverable via reflogreset-recoverable-head
Signing-aware UI (gpgsign config set)signed-commits-required
Freshly initialised, no commits yetempty-repo

Worktree & stash scenarios

GoalScenario
Single staged file, ready to commitsingle-staged-file
Mixed: some staged, some unstaged, some untrackedpartial-stage
Many files across multiple dirs (12 staged, 6 unstaged, 3 untracked)dirty-many-files
Monorepo with packages in different statesmonorepo-multi-package
Multiple linked worktreesmultiple-worktrees
Clean main plus several stashesstashed-changes
One stash that includes untracked filesstash-with-untracked
Git LFS pointer file (no git-lfs binary required)git-lfs-pointer
.gitattributes CRLF normalisationcrlf-normalization
Case-only filename collisioncase-collision

Operation scenarios

GoalScenario
In-progress merge with a conflictmid-merge-conflict
In-progress rebase with a conflictmid-rebase-conflict
In-progress cherry-pick with a conflictmid-cherry-pick-conflict
In-progress revert with a conflictmid-revert-conflict
Merge with a rename/rename conflictmerge-conflict-rename-rename
Merge with a delete/modify conflictmerge-conflict-delete-modify
Merge with an add/add conflictmerge-conflict-add-add
Completed --no-ff merge (2-parent commit at HEAD)merge-no-conflict
Active git bisect in progressmid-bisect

History scenarios

GoalScenario
Rich graph: many commits, merges, live unmerged branchrich-history-graph
Large repo for pagination/performance testinglarge-repo
Shallow clone (.git/shallow set)shallow-clone
Commits with different branch-tip chip kindschip-rendering-showcase

Submodule scenarios

GoalScenario
Parent with a cleanly pinned submodulesubmodule-with-history

Step 3 — Nothing fits?

If no curated scenario matches your case exactly, you have two options:

Extend an existing scenario with fromScenario:

import { fromScenario, addCommit, writeFiles } from '@gfargo/git-scenarios'
const repo = await fromScenario('feature-pr-ready',
addCommit({ message: 'extra commit', files: { 'extra.ts': 'x\n' } }),
writeFiles({ 'dirty.ts': 'uncommitted\n' }),
)

Compose from atoms if you need full control:

import { createTempGitRepo, chain, addCommit, startMerge } from '@gfargo/git-scenarios'
const repo = await createTempGitRepo()
await chain(
addCommit({ message: 'base', files: { 'x.ts': 'base\n' } }),
// ... your atoms here
)(repo)

For reusable custom states, see Custom Scenarios → and the Atom reference →.

See also