---
title: "Synchronize items between remote and local SitecoreAI instances with the Sitecore CLI"
slug: "synchronize-items-between-remote-and-local-sitecoreai-instances-with-the-sitecore-cli"
abstract: "Describes how to run serialization operations between local and remote SitecoreAI environments"
---
# Synchronize items between remote and local SitecoreAI instances with the Sitecore CLI

When multiple developers develop a SitecoreAI solution or when using multiple SitecoreAI environments, you can synchronize the databases for the environments using Sitecore Command Line Interface (CLI) [serialization commands](https://doc.sitecore.com/sai/en/developers/sitecoreai/sitecore-command-line-interface/sitecore-cli-command-reference/the-cli-serialization-command.html "The CLI serialization command"). You can use CLI serialization commands against local and remote SitecoreAI Content Management (CM) environments.

> [!note]
> **Before you begin**
> You must have the following:
>
> -   [.NET 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0).
>
> -   A [SitecoreAI\-compatible solution, running locally](https://doc.sitecore.com/sai/en/developers/sitecoreai/using-docker-for-full-stack-development/set-up-your-full-stack-sitecoreai-local-development-environment.html "Set up your full-stack SitecoreAI local development environment").
>
> -   A remote [Sitecore CM instance](https://doc.sitecore.com/sai/en/developers/sitecoreai/sitecore-command-line-interface/create-a-sitecoreai-project-using-the-sitecore-cli.html "Create a SitecoreAI project using the Sitecore CLI").
>
> -   [Sitecore CLI version 5.0](https://doc.sitecore.com/sai/en/developers/sitecoreai/sitecore-command-line-interface/install-and-setup-sitecore-cli/install-sitecore-command-line-interface.html "Install Sitecore Command Line Interface") or later, with the [XM Cloud plugin](https://doc.sitecore.com/sai/en/developers/sitecoreai/sitecore-command-line-interface/plugins/xm-cloud-plugin.html "XM Cloud plugin") installed.
>
>
> Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

This walkthrough describes how to:

- Log in to the CLI
- Connect the CLI to a remote SitecoreAI environment.
- Run serialization operations.

## Log in to the CLI

To log in to the CLI:

- In the project working directory, in a command-line window, log in to SitecoreAI using the CLI by running the command:

    ```shell
    dotnet sitecore cloud login
    ```

Follow the steps in the user interface to log in and authorize your device.

## Connect the CLI to the SitecoreAI environment

To support running commands such as `serialization push` on a remote SitecoreAI CM instance, you must connect the Sitecore CLI plugins to the remote environment.

> [!note]
> If you followed the walkthrough to [set up your full-stack local development environment](https://doc.sitecore.com/sai/en/developers/sitecoreai/using-docker-for-full-stack-development/set-up-your-full-stack-sitecoreai-local-development-environment.html "Set up your full-stack SitecoreAI local development environment"), you can skip this section. If you have not, and you encounter issues, refer to that documentation for any steps you might have missed in your setup.

To connect the CLI to a remote SitecoreAI environment:

- In a command-line window, in the project working directory, run the `cloud environment connect` command and enter the environment ID:

    ```
    dotnet sitecore cloud environment connect --environment-id <environment-id> --allow-write
    ```
    > [!tip]
    > You can retrieve the environment ID by running the following command:
    >
    > dotnet sitecore cloud environment list --project-id <project-id>

    The command creates a new endpoint or updates an existing endpoint for the connected environment in the `.sitecore/user.json` file.

    ![Example of a resulting user.json file](https://doc.sitecore.com/api/markdown-image/sai/en/developers/sitecoreai/images/user_json_example.png)

When connected, you can use Sitecore CLI commands that run against a remote instance. You specify the instance with the option `--environment-name` (or `-n` ) with the value of an endpoint key defined in the `.sitecore/user.json` file. For example:

```shell
dotnet sitecore index list --environment-name development
```

## Run serialization operations

With a connected CLI, you can run serialization pull and push operations against the remote Sitecore XM CM instance. You must provide the environment name, as defined in the `.sitecore/user.json` file.

To pull items from the remote CM instance to the local file system:

- In a command-line window, in the project working directory, run the command:

    ```shell
    dotnet sitecore serialization pull -n development
    ```

To push items from the local file system to the remote CM instance:

- In a command-line window, in the project working directory, run the command:

    ```shell
    dotnet sitecore serialization push -n development
    ```
    > [!note]
    > The `serialization push` command does not publish items. To publish content in an environment, refer to [Publish and validate content](https://doc.sitecore.com/sai/en/developers/sitecoreai/sitecore-command-line-interface/publish-and-validate-content-for-testing-purposes-using-the-sitecore-cli.html "Publish and validate content for testing purposes using the Sitecore CLI").

You can also run [other Sitecore CLI commands](https://doc.sitecore.com/sai/en/developers/sitecoreai/sitecore-command-line-interface/sitecore-cli-command-reference.html "Sitecore CLI command reference") in the SitecoreAI environment by providing the environment name.