> ## Documentation Index
> Fetch the complete documentation index at: https://docs.entire.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Mirror Repositories in the CLI

> Create GitHub repository mirrors with the Entire CLI and configure Git remotes.

A [mirror](/guides/repositories/mirrors) is a synced, read-optimized copy of a GitHub repository, hosted on [Entire's Git network](/guides/repositories/overview) in the region you choose.

Use the CLI when you want to create a mirror from the terminal, script mirror setup, or immediately configure Git remotes. For the web flow, see [Mirrors in Entire.io](/guides/repositories/mirrors-in-entire-io).

## Before you start

Make sure you have:

* [Entire installed](/installation)
* access to clone the GitHub repository you want to mirror
* the [Entire GitHub App authorized](/guides/repositories/github-app-access) for the repository

## Log in

Log in with the Entire CLI:

```bash theme={null}
entire login
```

Confirm that your login is active:

```bash theme={null}
entire auth status
```

## Create the mirror

Run the create command with no arguments:

```bash theme={null}
entire repo mirror create
```

Entire lists the GitHub repositories you can mirror, then prompts you to select repositories and regions. Each repository is mirrored into every region you select, and Entire creates the mirrors in parallel:

```text theme={null}
Select repos to mirror
Space to select, enter to confirm.

> [•] <owner>/<repo>

Select regions to mirror into
Each repo is mirrored into every selected region.

> [•] us-east (us)
  [•] eu-west (eu)

REPO            REGION        STATUS  CLONE URL
<owner>/<repo>  us-east (us)  ready   entire://aws-us-east-2.entire.io/gh/<owner>/<repo>
<owner>/<repo>  eu-west (eu)  ready   entire://aws-eu-central-1.entire.io/gh/<owner>/<repo>
```

This registers the mirrors on Entire. It does not change any local Git checkout.

### Script the mirror creation

To create a mirror without prompts, pass the repository, and optionally the region's cluster host, as arguments:

```bash theme={null}
export GH_OWNER="<owner>"
export GH_REPO="<repo>"

entire repo mirror create "github.com/$GH_OWNER/$GH_REPO" aws-us-east-2.entire.io
```

The repository can be written as `owner/repo`, an HTTPS GitHub URL, or an SSH GitHub URL. If you omit the cluster host, an interactive terminal prompts you to pick a region; non-interactive runs default to `aws-us-east-2.entire.io`. To mirror into more than one region from a script, run the command once per cluster host.

The command waits until the initial clone from GitHub is available, then prints the mirror URL:

```text theme={null}
Registered mirror <mirror-id>
  entire://aws-us-east-2.entire.io/gh/<owner>/<repo>
  cloning. ready
```

Creating a mirror is idempotent for a given repository and region: rerunning the command returns the existing mirror. To return as soon as the mirror is registered instead of waiting for the initial clone, pass `--no-wait`.

## Use the mirror with Git

To clone the mirror into a new checkout, use the URL printed by `entire repo mirror create`:

```bash theme={null}
git clone "entire://aws-us-east-2.entire.io/gh/$GH_OWNER/$GH_REPO"
```

From an existing clone of the GitHub repository, point the local `origin` remote at the mirror:

```bash theme={null}
cd "$GH_REPO"
git remote get-url origin
git remote set-url origin "entire://aws-us-east-2.entire.io/gh/$GH_OWNER/$GH_REPO"
git fetch origin
```

If you want to verify the mirror before changing the checkout's primary remote, add it temporarily as another remote:

```bash theme={null}
cd "$GH_REPO"
git remote add entire "entire://aws-us-east-2.entire.io/gh/$GH_OWNER/$GH_REPO"
git fetch entire
```

These commands only update your local `.git/config`. They do not create or delete the server-side mirror.

## Push through the mirror

Push to the configured remote with normal Git commands:

```bash theme={null}
git push -u origin <branch>
```

Entire forwards the push through the mirror to the upstream GitHub repository. Your GitHub write access, branch protection rules, and required checks still apply.

## Push an unmirrored branch

Branches whose names start with `entire/unmirrored/` are never forwarded to GitHub. The branch stays in the mirror's Entire region, so pushes to it are not subject to GitHub's push rate limits. See [Unmirrored branches](/guides/repositories/mirrors#unmirrored-branches) for when to use them.

Create and push an unmirrored branch with normal Git commands:

```bash theme={null}
git switch -c "entire/unmirrored/<branch>"
git push -u origin "entire/unmirrored/<branch>"
```

When you want the work on GitHub, push the same commits to a branch name outside the prefix:

```bash theme={null}
git push origin "entire/unmirrored/<branch>:<branch>"
```

<Warning>
  Entire does not currently back up unmirrored branches, and they are not available on GitHub or from mirrors in other regions. Keep a copy of any work you cannot afford to lose on a mirrored branch or on GitHub.
</Warning>

## Remove the mirror

When you no longer need the mirror, remove the server-side mirror placement:

```bash theme={null}
entire repo mirror remove "github.com/$GH_OWNER/$GH_REPO"
```

Removing a mirror does not delete or rewrite the GitHub repository. It also does not change any local Git remotes you configured in `.git/config`.

## Continue with

<CardGroup cols={2}>
  <Card title="Mirror a GitHub Repository" icon="terminal" href="/learn/mirror-a-github-repository">
    Follow the end-to-end tutorial for creating, cloning, pushing through, and restoring a mirror.
  </Card>

  <Card title="Mirrors in Entire.io" icon="browser" href="/guides/repositories/mirrors-in-entire-io">
    Configure GitHub access and choose repositories from the web app.
  </Card>

  <Card title="Mirror Access and Permissions" icon="lock" href="/guides/repositories/mirror-access-and-permissions">
    Understand GitHub-synced access, hourly collaborator sync, and offboarding.
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/guides/repositories/troubleshooting">
    Fix missing repositories, app access, clone, fetch, and push issues.
  </Card>
</CardGroup>
