gg reconcile
Repair gg’s state when things happened outside gg: an interrupted command left
a recovery marker behind, or branches and PRs were pushed without gg sync.
gg reconcile [OPTIONS]
Options
-n, --dry-run: Preview only; make no changes. Lists every leftover marker and what it resolves to. A dry run writes nothing, not even an entry ingg undo --list.-y, --yes: Skip the confirmation prompt. On its own it approves metadata normalization (which rebases the stack). With--discard-pendingit confirms only the discard. Use for non-interactive callers such as agents, MCP, or CI when you intentionally want reconciliation to proceed.--discard-pending: Also remove the markers gg cannot settle, after printing what each one abandons: markers whose outcome the forge cannot determine, and pending branch deletions that no stack owns any more. Nothing remote is changed. Metadata normalization is not applied in the same run; it is reported, and a plaingg reconcileapplies it. Cannot be combined with--dry-run. With--jsonit requires--yes.--json: Print one JSON document instead of human output. A JSON caller cannot answer the normalization prompt, so without--yesthe stack is not rebased (normalized: false).
What it does
-
Settles leftover recovery markers. When a command such as
gg syncorgg landsends a request and never sees the answer (the process was killed, the network dropped), it leaves a marker ingg/config.jsonso the next run does not repeat the request blindly.gg reconcilereads the forge for every marker, across all stacks (including stacks you have since removed and pending remote-branch deletions), and acts on what it finds:- completed: the request took effect. gg finishes its bookkeeping (for example, maps a review that was created) and clears the marker.
- not applied: the request did not happen or no longer matters. The
marker is cleared, so the next
gg syncorgg landredoes the step if it still applies. A replaced-review follow-up or a pending branch deletion is kept forgg sync/gg cleanto retry; reconcile itself never comments, closes, merges or deletes anything. - undetermined: the forge could not be read, or its answer is
ambiguous (for example, two open reviews from the same branch). The marker
is kept. Retry once the forge is reachable, or abandon it with
--discard-pending.
A land intent is a queued remote branch deletion that
gg landleft for a merged entry.--dry-runlists it as a remote deletion together with its review (for examplePR #101), andgg cleannormally deletes the branch.--discard-pendingdrops it and keeps the remote branch.A pending branch deletion whose stack was removed (or renamed, or whose
branch_usernamechanged) has no owner: nogg syncorgg cleanwill retry it. Reconcile says so, and--discard-pendingdrops it.A completed GitLab pipeline handoff (the pipeline
gg landstarted for an MR) is not a pending marker and is not listed while it still applies. Reconcile lists it as completed and clears it once the MR is merged, closed or at another head, and as undetermined when the MR cannot be read or the handoff’s operation record is missing or does not back it.It also handles this worktree’s interrupted-rebase marker: a stale one (the rebase was ended with plain
git rebase --abort) is cleared, and one that contradicts the rebase in progress can be discarded with--discard-pending, which keeps the rebase itself. Seegg continue/gg abort. -
Normalizes GG metadata trailers on the current stack’s commits (
GG-ID+GG-Parent). This rebases the stack, so it asks first unless you pass--yes. -
Maps existing remote PRs/MRs back to the current stack’s entries.
Without a usable provider (none detected, its CLI missing, or not
authenticated), reconcile still settles the markers that need none: pending
remote branch deletions, which it reads from the remote, and this worktree’s
interrupted-rebase marker. Every other marker is listed as unknown and kept
(even with --discard-pending), steps 2 and 3 are skipped, and the human
output says they need the provider. It exits 0. When there is nothing of that
kind to settle, a run without --dry-run fails with the provider error, as
before.
When HEAD is not on a stack, only the marker step runs; if there are no markers either, reconcile stops with the usual “not on a stack” error. While a rebase is in progress, steps 2 and 3 are skipped, so reconcile never starts a rebase on top of a paused one.
An error from gg sync, gg land or gg clean that names gg reconcile
means one of these markers could not be settled automatically. Start with
gg reconcile --dry-run.
Discarding a marker
--discard-pending gives up on what the marker tracked. Each line says what
that means, so check the forge before the next command:
- a lost review creation: a review may exist on the forge for that branch.
If none is mapped, the next
gg syncopens a new one. - a direct merge, merge-train queue or GitLab landing request: the review may already be merged or queued.
- a replaced-review follow-up: gg no longer comments on or closes the old review.
- post-merge maintenance: the attempted retargets, pushes or local rebases
are forgotten, and the next
gg landredoes them. - a land intent (the queued deletion of a landed entry’s branch): gg stops
trying to delete it, and the remote branch stays. Delete it yourself with
git push origin --delete <branch>if you no longer need it. - a remote branch deletion (undetermined, or owned by no stack): gg gives up its authority to delete the branch, so the remote branch is left in place. Delete it yourself if it is no longer needed.
Examples
# See every leftover marker and what it resolves to; nothing changes
gg reconcile --dry-run
# Apply what the forge settles; undetermined markers stay
gg reconcile
# Also abandon what the forge cannot settle
gg reconcile --discard-pending
# Non-interactive / agent usage
gg reconcile --dry-run --json
gg reconcile --discard-pending --yes --json
A dry run with one marker of each outcome:
→ 3 pending recovery markers (dry run: nothing changed):
• feat: review creation for alice/feat--c-2222222 into main: undetermined (open PRs from alice/feat--c-2222222 could not be listed (...: connection refused))
• feat: direct merge of #41 at 1111111: not applied (the marker would be cleared)
• deletion of origin/alice/gone--c-3333333 at 1111111…: completed (the marker would be cleared)
Run `gg reconcile` to apply; undetermined markers stay until the forge can answer, or `gg reconcile --discard-pending` abandons them.
Discarding the undetermined one:
! Discarding pending markers gg cannot settle:
• feat: review creation for alice/feat--c-2222222 into main: a review may exist on the forge for this branch; check it before the next `gg sync`, which opens a new one if none is mapped
OK Discarded 1 marker.
JSON output
{
"version": 1,
"dry_run": false,
"markers": [
{
"stack": "feat",
"kind": "review_creation",
"key": "c-2222222",
"review": null,
"summary": "review creation for alice/feat--c-2222222 into main",
"resolution": "undetermined",
"reason": "open PRs from alice/feat--c-2222222 could not be listed (...)",
"consequence": "a review may exist on the forge for this branch; check it before the next `gg sync`, which opens a new one if none is mapped",
"discarded": true
}
],
"stack": "feat",
"commits_needing_ids": [],
"reviews_to_map": [],
"normalized": false
}
markers[].kind:review_creation,direct_merge,gitlab_landing,gitlab_train_queue,replacement_followup,land_maintenance,remote_deletion, orinterrupted_rebase.stackis empty for repository-wide markers (remote deletions, this worktree’s rebase marker).markers[].resolution:completed,not_applied,undetermined,unknown(the provider cannot be detected or its CLI is missing or not authenticated;reasonsaysprovider unavailable; remote deletions are still read from the remote), orin_progress(a paused rebase gg still owns; finish it withgg continueorgg abort).markers[].consequence: what discarding the marker abandons (the line printed before discarding). Set when--discard-pendingwould remove the marker or did;nullotherwise.markers[].discarded: whether--discard-pendingremoved it.stack,commits_needing_ids,reviews_to_map,normalized: the stack step.stackisnullwhen HEAD is not on a stack.
gg reconcile exits 0 when undetermined markers remain; check resolution.