gg land
Merge approved PRs/MRs from the bottom of your stack upward.
gg land [OPTIONS]
Options
-a, --all: Land all approved entries in sequence--auto-merge: (GitLab only) Request auto-merge instead of immediate merge--no-squash: Disable squash merge (squash is default). On GitLab, gg also turns off the MR’s own squash setting before merging or queueing it, and refuses up front when the project requires squashing--no-rebase: Don’t rebase and force-push the remaining stack branches after each merge. Avoids re-triggering CI on every remaining PR/MR; intended for--no-squash, where original commit SHAs stay reachable from the base branch--rebase-if-needed: After each merge, rebase the remaining branches only when needed (see Rebasing remaining branches). Conflicts with--no-rebase-w, --wait: Wait for CI and approvals before merging-u, --until <UNTIL>: Land up to a target entry (position, GG-ID, SHA)-c, --clean: Clean stack automatically after landing all. Auto-clean (--clean,land_auto_cleanor the prompt) runs only after an error-free landing--no-clean: Disable auto-clean for this run--admin: (GitHub only) Use admin privileges to bypass branch protection requirements (see Admin Override below)--json: Emit machine-readable JSON output (no human logs)--jsonl: Emit flushed NDJSON events as landing and polling progress; conflicts with--json
A plain gg land (one PR, without --all, --wait, --json or --jsonl)
asks “Merge PR #N?” before merging. Without a terminal to answer it (a script,
CI, an agent), it merges nothing and exits with an error; pass --json (or
--all) to land without the prompt.
For non-wait landing, gg refreshes approval for each entry immediately before
its final queue or merge request. If approval was dismissed after the initial
stack refresh, that entry is refused without starting the landing mutation.
Only the explicit GitHub admin override bypasses this check; GitLab still
requires approval when --admin is supplied.
Wait-mode direct merges use the same final approval refresh. This includes each
entry selected by --all or --until, so a missing or dismissed approval stops
the command before it creates landing recovery state or sends the merge request.
GitLab auto-merge queueing also refreshes approval in wait mode, immediately before creating recovery state and asking GitLab to merge when the pipeline succeeds. GitLab admin settings do not bypass this check.
The initial GitLab merge-train queue request has the same boundary: after the
final MR or pipeline-handoff validation, gg refreshes approval before creating
queue recovery state or sending the queue request. A refusal leaves neither an
initial queue attempt nor landing recovery state, even with --admin.
If a push cancels auto-merge while --wait is tracking the train, the requeue
has its own authorization and recovery boundary. gg re-reads and validates the
MR, requires its current head SHA, and refreshes approval before recording or
sending the requeue. GitLab --admin does not bypass this check.
For every GitLab landing with --no-squash, including --wait, gg also
refreshes approval inside the durable squash segment immediately before changing
the MR’s setting. This happens after the final identity and policy checks. If the
setting is already disabled, gg skips both approval lookup and the PUT. If
approval was dismissed or cannot be read, gg leaves the setting unchanged,
records the segment as a committed untouched no-op, clears its attempt marker,
and stops before any later landing mutation.
In GitLab merge-train wait mode, gg refreshes approval after validating that a pipeline is still missing and immediately before asking GitLab to create it. If approval was dismissed while waiting, gg sends no pipeline request and records the prepared operation as a proven no-op.
Landing only the reviewed commit
When gg decides a PR/MR is ready to land, it records exactly what it checked: the PR/MR number, source branch, head commit, and target branch. Right before each merge, merge-train queue, requeue, or auto-merge request, it reads the PR/MR again and compares. If anything changed, gg refuses to land, so a push after approval is never merged unreviewed. Only after that check does it confirm approval for that exact commit.
The request also carries the expected head commit, so the forge itself
rejects it if the branch moves in the last moment: GitHub merges use
--match-head-commit, and GitLab merge, merge-train, and auto-merge requests
pass sha. If the forge reports no head commit, gg refuses to land.
Resuming after an interrupted land
Before each remote request (a direct merge, a GitLab merge-train queue or
requeue, an auto-merge queue, a post-merge retarget or push) gg saves a small
attempt marker in .git/gg/config.json. A marker that is still there when
gg land starts means an earlier run did not see how its request ended: the
process was killed, the network dropped, or a later step failed.
gg land does not compare your local branches with a snapshot to decide what
happened. It asks GitHub or GitLab, identifying the review by its number and,
when the marker recorded one, by its head commit:
| Marker | The provider shows | Result |
|---|---|---|
| Direct merge | merged at the recorded head (or the operation already recorded the merge) | Completed: the entry is finished as already merged |
| Direct merge | open at the recorded head and not queued | Not applied: marker removed, gg merges normally |
| Direct merge | open at another head, closed, or merged at another head | Not applied: the old attempt is moot (for example you amended and synced) |
| Direct merge | merged at the recorded head into another target, or queued to merge | Undetermined |
| Merge-train queue or requeue | merged, on the train, or set to auto-merge, at the recorded head | Completed |
| Merge-train queue or requeue | open and not queued, or open at another head, or closed | Not applied |
| Auto-merge queue | merged, or open with auto-merge set, at the recorded head | Completed |
| Auto-merge queue | anything else | Not applied |
| Post-merge retarget | the review already targets the new base | Completed |
| Post-merge retarget | any other base | Not applied: gg retargets it again |
| Post-merge push | the remote branch holds the pushed commit | Completed |
| Post-merge push | anything else | Not applied: gg pushes again, with the branch’s pre-rebase commit as the lease |
| Local downstream rebase | the branch is still at its pre-rebase commit | Not applied: gg rebases it again |
| Local downstream rebase | the branch moved and no rebase of it is in progress | Completed |
| Completed local rebase | the branch was rewritten since (for example amended and synced) | dropped with its push; gg works from the branch as it is now |
| Merge-train queue or requeue | an idle car (still waiting for its pipeline) on the train | Completed |
| GitLab pipeline creation | a head pipeline exists at the recorded head | Completed: kept as the pipeline hand-off |
| GitLab pipeline creation | the MR is at the recorded head with no pipeline | Not applied |
| GitLab squash update | the MR’s squash setting is off | Completed: kept as the squash hand-off |
| GitLab squash update | squash is still on | Not applied: turning it off again is harmless |
| Any | the provider or remote cannot be read, the MR moved to another head (pipeline), or a rebase is still in progress | Undetermined |
A marker whose operation record proves the request was never sent is removed without asking the provider. Markers written by v0.10.11 resolve the same way; when they lack the head commit, the review number alone identifies them.
For a local rebase gg looks only at the rewritten branch’s tip and at whether
a rebase of that branch is still in progress (in this worktree, or in another
linked worktree that is rebasing the same branch). Moving an
unrelated branch, amending a commit, or a commit added to the PR/MR on the
forge (“Update branch”, an accepted suggestion) does not block recovery. When
the forge head differs from your local entry branch, gg land prints a note on
stderr and lands the forge head, which is the one that was reviewed and
approved.
Undetermined keeps the marker and stops gg land for that stack only.
Other stacks still land. The error lists each pending marker and ends with:
Run `gg reconcile --dry-run` to inspect, or `gg reconcile --discard-pending` to abandon them.
A resumed gg land without --all finishes the interrupted entry and stops,
exactly as the interrupted run would have.
After a merge: retargets, rebases, and pushes
Once a PR/MR merges, gg records the merge and finalizes it before it prints
anything or touches the rest of the stack. Each follow-up step then runs and
is recorded on its own: retargeting each remaining active PR/MR to the base
branch, then rebasing and force-pushing each remaining active review branch with
an exact lease. Reviews observed merged or closed are skipped by all three steps.
gg refuses to rebase the remaining branches while tracked files have uncommitted
changes, staged or not, and never overwrites them when it restores your checkout;
commit or stash them, then rerun gg land to finish the rebases.
Before each request, gg saves that it is about to happen. After a
success, it records exactly what changed before it moves on or prints the next
line. gg undo never reverses these records, not even a local rebase step.
A failed retarget or push is reported as a gg land error, not as a warning
followed by success. Before retargeting, gg saves the review’s source branch, its
current base and the intended base, then re-reads the review immediately before
the update and requires the same review number, an open state, source and
current base. A mismatch sends no retarget. A draft review is retargeted like any
other and stays a draft: retargeting is not merging, and gg land still skips
the draft when it reaches it. The next gg land resolves any
pending retarget, push, or local rebase from the provider and the branches it
rewrote, as described in Resuming after an interrupted land.
When a remaining entry has no local branch (for example in a fresh clone), gg
creates it from origin/<branch> before rebasing it. An existing local branch
is always used as it is. If neither exists, gg land stops and names the
branch; run git fetch origin or gg sync, then rerun it.
Reviews at the bottom of the stack that were merged on the forge, outside gg,
are completed the same way before gg lands the next one, with or without
--clean: their downstream reviews are retargeted and rebased first, so the
next merge goes into the base branch rather than into the merged predecessor’s
branch.
Direct merges, retargets, and pushes change no local branch. If HEAD, the
stack branch, or one of its entry branches moves while a direct merge is in
flight, gg stops before completing that review; the next gg land resolves the
merge from the provider and finishes it.
Remote entry branches after landing
Each merged entry’s remote branch is queued for deletion at the merged commit,
with or without --clean, even when no local entry branch exists. When
the whole stack lands and --clean cleanup runs, gg drains the queue right
away; otherwise the next gg clean deletes the branches.
The whole stack does not have to land in one run. An entry an earlier
gg land merged counts as landed when the commit it merged is still the one in
your local stack, so gg land --all --clean also cleans up after you landed the
bottom of the stack with plain gg land runs, after a rerun following a
rejected merge of the second entry, or after one merge-train run per MR. An
entry that land rebased before merging it (the lower entries of a
multi-entry run, such as #102 when #101 and #102 merged and #103’s merge was
rejected) is not counted yet: the rerun lands the rest, keeps the stack and
reports cleaned: false, and gg clean finishes the cleanup. When the stack
is already empty and only its queued deletions are left (for example after a
deferred deletion), gg land --clean drains them and removes the stack
instead of printing “Stack is empty. Nothing to land.” A commit you added to
the stack with plain git and never landed still keeps the stack: gg does not
clean it up.
A branch is kept while an open review from outside the stack still targets it
(--clean then warns, reports cleaned: false and keeps its exit code), and a
branch that moved since the merge is never deleted. See
gg clean for the deferred
and blocked outcomes and for deleting branches older versions left behind.
Landing request outcomes
Every landing request (a direct merge, a GitLab auto-merge queue, or a merge-train queue or requeue) has two results: what the provider answered, and whether gg durably finalized the Land operation afterwards. gg reports both, so neither can hide the other, and it never prints a success result before the operation is durable:
- Provider succeeded, checkpoint failed: the command fails with a durability-checkpoint error that says the request succeeded remotely. It names the operation ID and the recovery authority (the saved attempt marker, or for a direct merge the Land operation record). Do not resend the request.
- Provider rejected the request: an explicit refusal from GitHub or GitLab
(for example
GraphQL: Required status check "ci" is expected, an HTTP 4xx such as422 Unprocessable Entity, orPull request is not mergeable) proves nothing was applied. The entry is reported as an error that says the request “was rejected by the provider”, gg removes the attempt marker, and it is safe to fix the cause (wait for checks, amend andgg sync, get the approval) and rungg landagain. - Provider failed otherwise, checkpoint succeeded: a killed
gh/glab, a network or TLS error, an HTTP 5xx, or output gg does not recognise leaves the outcome unknown, so gg reads the PR/MR once more. If it shows the merge or queue took effect, gg carries on as if the request had succeeded. If it shows nothing happened, gg removes the attempt marker and reports the error; it is safe to rerungg land. Only when that read also fails or is contradictory does the marker stay, and the error namesgg reconcile. - Both failed: the command fails with a remote-uncertainty error that carries both the provider error and the checkpoint error.
For a checkpoint failure, inspect the review in GitHub or GitLab and the named
operation in .git/gg/operations/ before rerunning gg land.
Examples
# Land one approved entry
gg land
# Land complete stack, waiting for readiness
gg land --all --wait
# Land part of stack
gg land --until 2
# GitLab auto-merge queue
gg land --all --auto-merge
# Land with merge commits; rebase remaining branches only when needed
gg land --all --wait --no-squash --rebase-if-needed
# JSON output for automation
gg land --all --json
# Stream landing progress and wait heartbeats
gg land --all --wait --jsonl
# Bypass approval requirements (GitHub admin)
gg land --admin
# Land full stack with admin override
gg land --all --wait --admin
Admin Override
The --admin flag (or land_admin config default) passes --admin to gh pr merge, which uses GitHub’s API-level admin merge. This bypasses all branch protection rules the merging user has permission to override, which may include both review approvals and required status checks depending on your repository settings.
Use --wait --admin if you want to wait for CI to pass before merging while still bypassing approval requirements. Without --wait, no client-side CI validation is performed.
On GitLab, --admin is a no-op — glab mr merge has no equivalent flag. A warning is printed and the merge proceeds normally.
A warning (⚠ Merging with admin override) is printed before each admin-elevated merge.
Downstream MR Retargeting
After landing an entry, gg land automatically retargets active downstream reviews so they no longer point at the now-merged intermediate branch:
- Single entry (
gg land): retargets the immediate next MR tostack.base. - All entries (
gg land --all): retargets all remaining MRs tostack.baseas each entry is landed.
Downstream reviews observed as merged or closed at command entry are left untouched by retargeting; the scanner still handles those terminal states normally. This applies to both GitHub PRs and GitLab MRs. No manual retargeting in the provider UI is needed for active downstream reviews after landing.
In a GitHub native stack GitHub retargets and restacks the downstream PRs itself, so gg skips this step and the rebase below.
Rebasing remaining branches
When you land several entries (--all or --until), gg land by default rebases every remaining active review branch onto the updated base and force-pushes it after each merge; reviews already observed as merged or closed at command entry are skipped. That keeps squash merges working, but every force-push re-runs CI on every remaining active PR/MR.
With --rebase-if-needed, gg checks two things after each merge and skips the rebase when both hold:
- The landed commit itself is reachable from the freshly fetched
origin/<base>, so it landed through a merge commit rather than as a squashed or rebased copy. - The forge reports that the next PR/MR, already retargeted to the base, can merge as-is. On GitHub that means
mergeableis notCONFLICTINGandmergeStateStatusis notDIRTYorBEHIND. On GitLab it means no conflicts and adetailed_merge_statusother thanconflictorneed_rebase.
Forges compute mergeability in the background after a retarget, so gg polls for up to a minute. If the answer is still unknown, or either check fails, gg rebases exactly as it does by default. Only the next entry is checked: the entries above it target its branch, and that branch stays untouched when it isn’t rebased.
--no-rebase skips the rebase unconditionally. Prefer --rebase-if-needed unless you know the base branch keeps original commits.
GitHub native stacks
With GitHub stacks integration on (defaults.github.stacks_integration is
auto, the default, or force), gg sync can link a stack’s PRs into a
GitHub native stack. GitHub then refuses gh pr merge and any base change on
those PRs, and after a merge it retargets the next PR to the base branch and
rebases (restacks) the PRs above it itself. Before it lands anything,
gg land asks GitHub once whether the stack’s first open PR is in a native
stack, and if it is:
- Each PR merges through GitHub’s asynchronous merge endpoint, still bound to
the head gg validated and after the same approval and base checks. gg waits
for GitHub to finish the merge (up to about a minute and a half). If GitHub
is still working on it,
gg landstops with “GitHub is still merging PR #N”; rerun it and gg follows the request GitHub already holds instead of starting a second merge. If the base branch uses a merge queue and GitHub only adds the PR to the queue, gg does not count it as landed (the queue may still reject it):gg landstops with “GitHub added PR #N to its merge queue”, keeps the PR in the stack, and a rerun after it merges completes it. - gg does not retarget, rebase or force-push the remaining PRs; that is
GitHub’s restack. Right before it lands a PR, gg waits (up to about a
minute) for GitHub to have retargeted that PR to the base branch, so it only
ever waits for a PR this run lands:
--untiland a plaingg landnever wait for the PRs above. If GitHub has not retargeted it by then,gg landstops with an error naming the PR and changes nothing on it; entries merged earlier are already recorded, so rerungg landlater. --rebase-if-neededand--no-rebasehave nothing to do here. Cleanup (--clean, queued branch deletions) works as for any other stack.
# Land a whole native stack and clean up
gg land --all --clean
To keep the classic flow (gg retargets and rebases the remaining PRs), set
defaults.github.stacks_integration to off and do not link the PRs into a
native stack.
Merge Trains (GitLab)
When merge trains are enabled on the target branch, gg land adds MRs to the merge train instead of merging directly. It uses GitLab’s auto-merge: if the MR pipeline is still pending or running, GitLab marks the MR “set to be added to the merge train” and adds it once the pipeline passes. You don’t have to wait for CI before queueing, and the MR still joins the train if gg exits. The squash setting (--no-squash to disable) is sent with the request.
After a preceding MR merges, GitLab can retarget the next MR without starting a new pipeline. With --wait, if GitLab reports that the next MR needs CI and has no head pipeline, gg starts the MR pipeline before requesting auto-merge. An existing pipeline is left alone.
Before processing a GitLab stack, gg land reads the project’s merge-train setting and stops without mutating the remote if that setting is unavailable or malformed. Immediately before every MR squash update, merge, queue, or pipeline request, it re-reads the MR through the GitLab API and requires an explicit open, non-draft state with the expected target branch.
Pipeline creation recovery (GitLab)
Pipeline creation is a durable operation. Before the POST, gg records the target
project, MR IID, source project and branch, current source commit, and target
branch, then revalidates that immutable identity immediately before the request.
If the POST response is ambiguous, the attempt remains durably Attempted, the
command stops with an error that names gg reconcile, and gg never resends the
POST blindly, because that could create a duplicate pipeline. The next
gg land reads the MR: a head pipeline at the recorded head commit means the
POST took effect and the attempt becomes the completed hand-off; an MR at the
recorded head with no pipeline means it did not, and the attempt is cleared.
If the MR moved to another head or cannot be read, the attempt stays and
gg land stops with the gg reconcile error. If GitLab explicitly rejects the
POST (an HTTP 4xx), no pipeline was created: gg commits the segment as a no-op,
clears the attempt, and reports the rejection, so you can fix the cause and
rerun gg land.
Once GitLab returns a pipeline ID, gg durably records a Completed handoff. It
retains that handoff across restarts and stale provider reads until the matching
MR is observed merged or closed, then clears it transactionally before
continuing to another entry.
The handoff belongs to the MR head the pipeline was started for. If that head
moves (for example, the pipeline failed and you amended the entry and ran
gg sync), the next gg land drops the handoff and handles the new head as
usual: it starts a pipeline if GitLab reports none, rechecks approval, and binds
the queue request to the head it validated then. If the MR cannot be read, or
the handoff’s operation record is missing or does not match it, gg land
stops with the gg reconcile error; gg reconcile --dry-run lists the handoff
and gg reconcile --discard-pending drops it. Inside one run, a head that moves
after the pipeline was started still stops that run; rerun gg land.
For --auto-merge without merge trains, an ambiguous queue response is resolved by reading the MR once more: auto-merge set means it was queued, anything else means it was not and the marker is removed. gg never sends the queue request twice for one attempt.
GitLab only applies a squash flag that is true when queueing or merging, so an MR created while the project’s squash option is “Encourage” (default_on) would still be squashed. With --no-squash, gg therefore turns off the MR’s squash setting in its own durable Land segment. It rechecks project policy and the complete MR identity, then refreshes approval immediately before one PUT. An initially disabled setting is an unjournaled no-op; if the setting becomes disabled during final revalidation, gg instead commits the opened segment as untouched and clears its marker without consulting approval. Approval refusal or lookup failure does the same proven-no-op cleanup and stops downstream work. After a successful PUT, gg records pr_squash_updated and emits squash_checkpoint before any merge or queue request. If the project’s squash option is “Require” (always), gg land --no-squash fails before touching any MR.
If the PUT response is ambiguous, the command stops with an error that names gg reconcile. The next gg land reads the MR’s squash setting: off means the PUT took effect and the completed attempt is resumed; still on means it did not, and the attempt is cleared, so Land disables squash again (which is harmless to repeat). If the MR cannot be read, the attempt stays and gg land stops. A failed squash_checkpoint write also stops downstream work; the completed record is emitted and cleared on restart.
Approval is always required before an MR can enter the merge train queue — even with --all. If using --wait, the command will show “Waiting for approval…” until a reviewer approves the MR. A pipeline that has already failed or been canceled stops the command instead of queueing.
After queueing, GitLab can take time to report the MR in the merge train listing. With --wait, gg keeps polling until the configured land_wait_timeout_minutes instead of failing after a short not-found window. It still stops promptly if the MR is closed, GitLab reports it was skipped from the train, the MR pipeline fails before the MR joins the train, or repeated API errors occur.
If GitLab accepts the initial queue request but the response is lost, gg reads the MR and its merge-train entry once more. If the MR is on the train (or set to auto-merge, or merged), gg reports it queued and carries on; if not, it removes the attempt marker and reports the error, and rerunning gg land queues it. It never sends the queue request twice for one attempt. The completed pipeline handoff is kept either way.
GitLab cancels auto-merge when the MR’s source branch is pushed, and it does not add the MR back by itself. gg records the MR’s head commit when it queues the MR. When --wait sees the MR still open, off the train, and no longer set to auto-merge, it compares heads. If the head moved, a push cancelled the merge: gg queues the MR again with the same squash choice, records the new head, reports this in a wait event with status: "warning", and keeps polling. If the head did not move, the train pipeline failed or someone cancelled auto-merge by hand, so gg stops waiting with an error instead of queueing the MR again.
The requeue request is journaled separately from the initial queue. Before the
POST, gg durably records both the requeue owner and that remote work may begin.
It clears that recovery marker after GitLab confirms success, or explicitly
rejects the request, and the Land operation is finalized. After an ambiguous
response gg reads the MR once more: on the train means the requeue took effect
and the wait continues; off the train means it did not, the marker is removed
and the error is reported. A failed post-POST durability checkpoint keeps the
marker, and the next gg land resolves it from GitLab the same way, without
sending the requeue again. After a known
success, the waiter tracks the head SHA from the final MR validation rather than
the earlier polling snapshot.
Every GitLab queue action (the initial merge-train queue, a requeue, or an
auto-merge queue) follows the same order. gg first records in the operation
that remote work may begin, then saves the action’s attempt marker, and only
then sends the request. If the first write fails, nothing else happened. If
the marker cannot be saved, gg clears that first write again and commits the
operation as a no-op. Either way, no request was sent and you can simply
rerun gg land. If an older version left a marker whose operation never
recorded possible remote work, gg treats it as proof the request was never
sent, retires it without contacting GitLab, and continues.
Each GitLab queue or auto-merge operation records which action it is (merge-train
queue, requeue, or auto-merge) and the exact MR it acts on: stack, MR number,
target branch, source project and branch, source commit, and target project.
Before recovering a saved attempt, and before contacting GitLab or clearing
anything, gg checks that the operation names exactly one GitLab action, that
it matches the saved attempt, and that the recorded MR identity matches too.
Pipeline and squash recovery apply the same check. Any missing, duplicate, or
conflicting entry stops gg land and leaves the evidence untouched.
CI Failure Details
When using --wait, if CI fails on an MR the command stops and shows which jobs failed:
OK Landed 1 MR(s)
⚠ Landed 1 MR(s), but encountered an error:
Error: MR !7621 CI failed
Failed jobs: lint (stage: test), build-android (stage: build)
This helps diagnose CI issues without having to open the GitLab UI. Failed job names and stages are fetched from the MR’s head pipeline.
Concurrent commands while waiting
gg land --wait releases the repository-wide gg lock while it polls CI,
approvals, or merge-train state. You can run commands such as gg sync for a
different stack in another worktree during that time. Landing reacquires the
lock before every merge, rebase, push, cleanup, or config update. After
reacquiring it, Land resolves any merge-train queue marker left by another
process from GitLab before it continues, and stops (naming gg reconcile) only
if GitLab cannot tell what happened.
Do not change the stack being landed while it waits. If its commits, GG-IDs, or PR/MR mappings change, landing stops before the next merge and asks you to rerun the command with the latest stack state.
JSON Output
Example JSON response:
{
"version": 1,
"land": {
"stack": "my-stack",
"base": "main",
"landed": [
{
"position": 1,
"sha": "abc1234",
"title": "feat: add parser",
"gg_id": "c-abc1234",
"pr_number": 42,
"action": "merged",
"error": null
}
],
"remaining": 0,
"cleaned": false,
"warnings": [],
"error": null
}
}
If Land stops on a fatal error after it started, it still prints the land
object, with the entries landed before the failure, the remaining count, and
error, and exits 1. The entry Land was working on is listed last with
"action": "error": its merge or queue request may already have reached the
forge (the error says “succeeded remotely” when it did), so it still counts in
remaining until the next gg land settles it from the provider:
{
"version": 1,
"land": {
"stack": "my-stack",
"base": "main",
"landed": [
{ "position": 1, "sha": "abc1234", "title": "feat: add parser", "gg_id": "c-abc1234", "pr_number": 42, "action": "merged", "error": null },
{ "position": 2, "sha": "def5678", "title": "feat: add printer", "gg_id": "c-def5678", "pr_number": 43, "action": "error", "error": "Durability checkpoint error: direct merge for PR #43 succeeded remotely, but ..." }
],
"remaining": 1,
"cleaned": false,
"warnings": [],
"error": "Durability checkpoint error: direct merge for PR #43 succeeded remotely, but ..."
}
}
landed is not a list of merges. It can hold an entry with "action": "error",
which is not a merge, so filter on action (merged, already_merged, …)
instead of counting its length.
When --clean drained queued remote branch deletions, the land object also
has remote_deletions: {"deleted": ["<branch>"], "deferred": [{"branch": "...", "reason": "..."}], "blocked": [{"branch": "...", "reason": "..."}]}.
It is omitted when all three lists are empty. cleaned: false together with
deferred entries means a later gg clean finishes the job, not that landing
failed.
Only a failure before Land starts prints the bare {"version": 1, "error": "..."}
object without land.
Streaming NDJSON (--jsonl)
gg land --jsonl emits one compact JSON object per line and flushes each line.
Every event has version, command, status, and event. Human output is
suppressed. Use this mode to monitor a long-running --wait invocation.
Event kinds:
| Event | Fields | Emitted when |
|---|---|---|
start | stack, base, total_entries | A non-empty landing run begins |
pipeline_checkpoint | pr_number | A GitLab pipeline result and its operation finalization are durable |
squash_checkpoint | pr_number, squash | A GitLab squash update, exact effect, and operation finalization are durable |
wait | position, pr_number, phase, poll, elapsed_seconds, ci_status, approved, merge_train_status, merge_train_position, pipeline_running, error | Each readiness or merge-train provider poll completes |
entry | Same fields as an item in landed | An entry reaches an outcome |
summary | Same fields as the land object from --json | Landing finishes, including partial and fatal failures |
error | message | A fatal error; once Land has started, a summary follows |
phase is readiness while checking CI and approval, or merge_train after
queueing an MR. Fields that the current phase did not check are null.
Transient provider errors appear in a wait event with status: "warning" and
the command keeps polling. Unchanged states still emit a heartbeat on the
existing 10-second polling cadence.
For a recovered or newly completed pipeline operation, pipeline_checkpoint
is emitted only after the durable state is complete. If writing or flushing that
event fails, including a broken output pipe, landing stops before queueing the
MR or taking the next action.
Once Land has started (its provider check passed), the final event is always
summary. Consumers should inspect its error field: a landing failure Land
reports itself (for example an unapproved PR/MR, failed CI, or a failed
downstream push) keeps the existing exit status 0, while a fatal failure (for
example a merge that succeeded remotely but could not be recorded) emits
error, then the summary with "status": "error", and exits 1. Only a
failure before Land starts ends with a lone error event: for example not a
repository, the gg lock is held, unfinished replacement follow-ups, failed
provider authentication, or repository state written by a newer gg.
{"version":1,"command":"land","status":"ok","event":"start","stack":"my-stack","base":"main","total_entries":1}
{"version":1,"command":"land","status":"ok","event":"wait","position":1,"pr_number":42,"phase":"readiness","poll":1,"elapsed_seconds":0,"ci_status":"running","approved":true,"merge_train_status":null,"merge_train_position":null,"pipeline_running":null,"error":null}
{"version":1,"command":"land","status":"ok","event":"entry","position":1,"sha":"abc1234","title":"feat: add parser","gg_id":"c-abc1234","pr_number":42,"action":"merged","error":null}
{"version":1,"command":"land","status":"ok","event":"summary","stack":"my-stack","base":"main","landed":[{"position":1,"sha":"abc1234","title":"feat: add parser","gg_id":"c-abc1234","pr_number":42,"action":"merged","error":null}],"remaining":0,"cleaned":false,"warnings":[],"error":null}