> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/code-repository/3.0/use-harness-code/collaborate-and-develop/clone-repos.md).

# Clone

After you [create a repository](/code-repository/3.0/use-harness-code/manage-repositories/create-repo.md), you can work directly in the Harness Code UI, or clone the repository to your local machine and use your own IDE. Harness Code supports cloning over HTTPS and over SSH.

***

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* **Repository access:** You need **View** on the repository you want to clone, and **Push** if you intend to push changes back. Go to the [permissions reference](/harness-ai/use-harness-platform/platform-access-control/permissions-reference.md#code-repository) to review the permission list.
* **Git installed:** You need a local Git client. Partial clone requires Git 2.19 or later, so upgrade if you plan to use `--filter`.
* **SSH availability:** Cloning over SSH is behind the `CODE_SSH_ENABLED` feature flag. Contact [Harness Support](mailto:support@harness.io) to enable it.

***

### Clone over HTTPS <a href="#clone-over-https" id="clone-over-https"></a>

To clone a repository over HTTPS, do the following:

1. When viewing a repository in Harness Code, go to **Summary**, then select **Clone repository**.
2. If this is the first time you have cloned this repository, select **Generate Clone Credentials**, then copy the **Token** and store it somewhere secure. Clone credentials are shown only once.

   When you select **Generate Clone Credentials**, Harness Code creates an [API token](/harness-ai/use-harness-platform/automation/api/add-and-manage-api-keys.md) in your user profile.

   <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>Tokens carry many privileges. Treat your user tokens as passwords and store them securely.</p></div>
3. Copy the Git clone URL shown on the **Clone** dropdown, then use it to clone the repository through the Git command line or your preferred Git GUI tool.

   Git prompts you for your Harness user name and the API token that was shown when you generated clone credentials.
4. Work with the cloned repository as you would with any other Git repository, by creating commits, pushing to the remote, and pulling changes.

***

### Clone over SSH <a href="#clone-over-ssh" id="clone-over-ssh"></a>

Cloning over SSH suits you if you prefer key-based authentication over token-based authentication.

#### Add your SSH key to Harness <a href="#add-your-ssh-key-to-harness" id="add-your-ssh-key-to-harness"></a>

Before you clone over SSH, confirm you have a key pair and register the public key with Harness.

1. Check whether an SSH key pair exists on your machine:

   ```bash
   ls ~/.ssh/id_rsa.pub
   ```

   If the file does not exist, generate a key pair and press **Enter** to accept the defaults:

   ```bash
   ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
   ```
2. In the bottom-left corner of the Harness UI, click your **Profile** icon.
3. Select **+ SSH Key**.
4. Enter a name for the key, then paste your public SSH key.
5. Click **Save**.

*Paste the contents of your public key file, not the private key.*

#### Clone with the SSH URL <a href="#clone-with-the-ssh-url" id="clone-with-the-ssh-url"></a>

To clone a repository over SSH, do the following:

1. In Harness, navigate to the repository you want to clone, then copy its SSH URL.

   *Select SSH in the Clone dropdown to reveal the SSH URL.*

   The URL uses the following format:

   ```shell
   <USER_ID>@git.harness.io:<USER_ID>/<ACCOUNT_NAME>/<PROJECT_NAME>/<REPO_NAME>.git
   ```
2. From your terminal, run `git clone` with the URL in quotes:

   ```shell
   git clone '<USER_ID>@git.harness.io:<USER_ID>/<ACCOUNT_NAME>/<PROJECT_NAME>/<REPO_NAME>.git'
   ```

   For example:

   ```shell
   git clone 'AB12CD34EF56@git.harness.io:AB12CD34EF56/CODE/CODE/sample-app.git'
   ```
3. Change into the cloned directory and verify the remote:

   ```shell
   cd sample-app
   git remote -v
   ```

   The SSH URL appears as `origin`.

***

### Reduce transfer size with partial and shallow clone <a href="#reduce-transfer-size-with-partial-and-shallow-clone" id="reduce-transfer-size-with-partial-and-shallow-clone"></a>

By default, `git clone` downloads the entire commit history along with every blob and tree, which costs bandwidth and time on large monorepos and multi-service repositories. Harness Code supports Git filtering so you can avoid that cost.

Use the `--filter` flag to exclude blobs from the initial clone. Git fetches them lazily when you need them:

```shell
git clone --filter=blob:none <REPO_URL>
```

Combine filtering with a shallow clone to also truncate history:

```shell
git clone --depth=1 --filter=blob:none <REPO_URL>
```

Go to the [Git documentation for `--filter`](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt-code--filterltfilter-specgtcode) to review the full filter specification.

{% hint style="info" %}
Filtering options require Git 2.19 or later.
{% endhint %}

***

### Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

<details>

<summary>Cloning or pushing to a Harness Code repository returns HTTP 500 or curl 22 The requested URL returned error: 500</summary>

The HTTP request size often exceeded the client-side buffer limit. Run git config http.postBuffer 524288000 to raise the buffer to 500 MiB for the repository, then retry. If the error persists, contact Harness Support.

</details>

<details>

<summary>Git reports unexpected disconnect while reading sideband packet when cloning a Harness Code repository</summary>

The connection dropped mid-transfer, commonly from network instability, timeouts, or server-side limits. Retry on a stable connection, and use Git LFS for files of 1 GiB or more. Contact Harness Support if it continues.

</details>

<details>

<summary>Cloning or pushing files larger than 4 GiB fails on Git for Windows</summary>

Git for Windows can stop transferring files larger than 4 GiB. Run Git from Windows Subsystem for Linux (WSL), or contact Harness Support about Harness Artifact Registry for very large artifacts.

</details>

<details>

<summary>Cloning a Harness Code repository over SSH is rejected or the SSH URL is unavailable</summary>

SSH cloning is behind the CODE\_SSH\_ENABLED feature flag. Confirm the flag is enabled on your account, and that your public key is registered on your Harness user profile.

</details>

***

### Next steps <a href="#next-steps" id="next-steps"></a>

You have a local copy of your repository and know how to keep the initial transfer small.

* [Git LFS](/code-repository/use-harness-code/collaborate-and-develop/git-lfs.md): Store files of 1 GiB or more outside the main object store.
* [Branch](/code-repository/use-harness-code/collaborate-and-develop/branch.md): Create and manage branches in your clone.
* [Sign commits](/code-repository/use-harness-code/collaborate-and-develop/signing-commits.md): Prove authorship on the commits you push back.
