# swarmops sync

> Release: 0.11.0 · Last changed: 2026-10-22 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/commands/sync.md

Fetch the remote, land main's unpublished changes onto its head, move main there, and push it.

Changes the remote holds already (a SwarmOps-Changeset, SwarmOps-Squashed-From or SwarmOps-Land-Key line in one of its commits, or a change that merges as none) are dropped; the rest land onto the remote's head one by one, as land merges them. A remote that moved meanwhile makes it fetch and land again, up to --max-attempts. With --no-push it stops before the push, for a branch that takes pull requests only. It needs an identity: it moves main. sync status shows where main and the remote stand, offline.

```yaml
title: "swarmops sync"
description: "Land main's unpublished changes onto a git remote's head, and push them."
group: "remotes"
since: "0.2.0"
mutates: true
identity_required: true
mcp_tool: "sync"
envelope_op: "sync"
exit_codes: [0]
errors: []
syntax: "swarmops sync [OPTIONS] <REMOTE>\n       swarmops sync <COMMAND>"
```

## Syntax

```text
swarmops sync [OPTIONS] <REMOTE>
       swarmops sync <COMMAND>
```

## Required arguments

### `REMOTE`

Syntax: `<REMOTE>`.

The remote, by its name.

## Optional arguments

The command also takes the [global options](../cli.md#global-options).

### `--no-push`

Syntax: `--no-push`.

Land onto the remote's head and move main, but push nothing.

### `--max-attempts`

Syntax: `--max-attempts <N>`.
Default: `8`.

How many times to fetch and land again when the remote or main moved meanwhile: 1 to 32.

## Examples

### CLI

No recorded example yet.

### MCP

No recorded example yet.

## Return information

`result` is a `SyncResp` (`swarmops schema SyncResp` prints its JSON Schema).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `attempts` | `integer` | yes | How many attempts it took. |
| `branch` | `string` | yes | The followed branch. |
| `dropped` | `array of DroppedChange` | yes | The changes the remote held already. |
| `main` | `HeadMove` | yes | `main`'s changeset before and after. |
| `published` | `array of PublishedChange` | yes | The changes landed onto the remote's head, oldest first. |
| `remote` | `string` | yes | The remote, by its name. |
| `remote_head` | `HeadMove` | yes | The remote branch's commit before and after. |
| `status` | `SyncStatusKind` | yes | What the sync did. |
| `warnings` | `array of string or null` | no | What the sync has to say that did not stop it. Omitted when there is nothing. |

Envelope `op`: `sync`.

Exit codes:

- `0`: Success.

## Errors

No golden step shows this command failing yet.

Any command that opens a store may also fail with a store error, such as [`E_NOT_A_REPO`](../errors.md#e_not_a_repo), [`E_IO`](../errors.md#e_io) or [`E_STORE_CORRUPT`](../errors.md#e_store_corrupt); a command line the grammar refuses is [`E_INVALID_ARG`](../errors.md#e_invalid_arg) (exit 2).

## See also

- [`swarmops clone`](clone.md)
- [`swarmops remote add`](remote-add.md)
- [`swarmops remote remove`](remote-remove.md)
- [`swarmops remote list`](remote-list.md)
- [`swarmops fetch`](fetch.md)
- [`swarmops push`](push.md)
- [`swarmops sync status`](sync-status.md)
- [CLI reference](../cli.md)
- [Error codes](../errors.md)
