# swarmops clone

> Release: 0.11.0 · Last changed: 2026-11-13 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/commands/clone.md

Make a store from a git remote: a new store in --into, the remote recorded as --remote (origin), fetched, and its followed branch (--branch, else the remote's default branch) imported into main.

The URL is an https or ssh URL, or the scp form user@host:path; a plain http URL only to a loopback address. A URL holding a password is refused, and so is an http or https URL with a user part, whatever the user is: a token there cannot be told from a name (leave the token to git's credential helper, or name its variable with --token-env). An ssh URL keeps its user. Git 2.39 or later runs the transfer, with the user's own credentials, proxies and ssh configuration. It needs an identity, as git import does: it moves main. Run again into the same directory with the same URL, it continues an interrupted clone.

```yaml
title: "swarmops clone"
description: "Make a store from a git remote: fetch it, import its default branch into main, and record it as a remote."
group: "remotes"
since: "0.2.0"
mutates: true
identity_required: true
mcp_tool: ""
envelope_op: "clone_repo"
exit_codes: [0]
errors: []
syntax: "swarmops clone [OPTIONS] --into <DIR> <URL>"
```

## Syntax

```text
swarmops clone [OPTIONS] --into <DIR> <URL>
```

## Required arguments

### `URL`

Syntax: `<URL>`.

The remote's URL.

### `--into`

Syntax: `--into <DIR>`.

The directory to make the store in: absent or empty.

## Optional arguments

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

### `--name`

Syntax: `--name <NAME>`.

The repository's name (default: the URL's last path component, without .git).

### `--branch`

Syntax: `--branch <BRANCH>`.

The remote branch main follows (default: the remote's default branch).

### `--remote`

Syntax: `--remote <NAME>`.
Default: `origin`.

The name to record the remote under.

### `--token-env`

Syntax: `--token-env <VAR>`.

The environment variable that holds a token for the remote, by its name.

### `--lossy`

Syntax: `--lossy <CLASS>...`.

A class of content the import may drop or normalize, as git import's. Values: `gitlinks`: A submodule's entry: dropped; `paths`: A name that is no path component: not UTF-8, . or .., empty, or holding a /: dropped; `modes`: A mode git does not write, such as 100664: normalized; `tree_order`: A tree out of git's order, or naming an entry twice: put in order; `empty_trees`: An entry naming an empty tree: dropped; `nonstandard`: A commit whose bytes the changeset cannot keep: kept as its fields hold it; `all`: Every class.

## Examples

### CLI

No recorded example yet.

## Return information

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fetch` | `FetchResp` | yes | The clone's fetch. |
| `imported` | `integer` | yes | How many changesets the import into `main` added. |
| `main` | `string or null` | no | The changeset `main` names; omitted when the remote is empty. |
| `remote` | `RemoteInfo` | yes | The remote recorded. |
| `repo` | `RepoInfo` | yes | The new store. |

Envelope `op`: `clone_repo`.

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 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`](sync.md)
- [`swarmops sync status`](sync-status.md)
- [CLI reference](../cli.md)
- [Error codes](../errors.md)
