Clone
After creating a repository, you can work directly in the Harness Code UI or you can clone your repo to your local machine and use your favorite IDE.
Clone over HTTPS
-
When viewing a repository in Harness Code, go to Summary and select Clone repository.
-
If this is the first time you've cloned this repository, select Generate Clone Credentials, and then copy the Token and store it somewhere secure. Clone credentials are only shown once.
When you select Generate Clone Credentials, Harness Code automatically creates an API token in your user profile.
warningTokens carry many privileges; treat your user tokens as passwords and store them securely.
-
Copy the Git clone URL shown on the Clone dropdown, and use it to clone your repository through command line Git or with your preferred Git GUI tool.
When cloning the repository, you will be prompted for your Harness user name and the API token, which were shown when you generated clone credentials.
-
Once cloned locally, you can work with your Harness Code repository as you would with other Git repositories, by creating commits, pushing to the remote, pulling changes, and more.
Clone over SSH
You can clone any Harness Code Repository using SSH if you prefer key-based authentication.
This feature is behind the CODE_SSH_ENABLED feature flag. To enable it, contact Harness Support.
Prerequisites
- You must have an SSH key pair on your local machine. To check:
ls ~/.ssh/id_rsa.pub
If it does not exist, generate one:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Press Enter to accept the defaults.
- Add Your SSH Key to Harness
-
In the bottom-left corner of the Harness UI, click your Profile icon.
-
Select + SSH Key.
-
Enter a name for the key and paste your public SSH key.
-
Click Save.
Steps to Clone
- In Harness, navigate to the repository you want to clone and copy its SSH URL.
The format will look like this:
<USER_ID>@git.harness.io:<USER_ID>/<ACCOUNT_NAME>/<PROJECT_NAME>/<REPO_NAME>.git
- From your terminal, run:
git clone '<USER_ID>@git.harness.io:<USER_ID>/<ACCOUNT_NAME>/<PROJECT_NAME>/<REPO_NAME>.git'
Example:
git clone 'AB12CD34EF56@git.harness.io:AB12CD34EF56/CODE/CODE/sample-app.git'
- Change into the cloned repository directory and verify the remote:
cd sample-app
git remote -v
- You should see the SSH URL listed as
origin.
Partial and Shallow Clone Support (Filtering in git clone)
Harness Code Repository supports filtering during git clone operations to improve performance, especially for large monorepos or multi-service repositories.
When cloning large repositories, the default behavior of Git is to download the entire commit history and all associated blobs/trees, resulting in significant bandwidth usage and long clone times. To address this, you can use Git’s built-in partial clone and shallow clone features with Harness-hosted repositories.
You can use the --filter flag with git clone against Harness Code Repositories:
git clone --filter=blob:none <REPO_URL>
Refer to the official Git documentation on --filter.
This reduces the amount of data transferred during clone by excluding blobs initially. They are fetched lazily only when needed.
You can also combine this with shallow clone options:
git clone --depth=1 --filter=blob:none <REPO_URL>
Make sure your Git version is 2.19 or later to use filtering options.
Troubleshooting (clone and push)
HTTP 500 or curl 22 when cloning or pushing
Error: HTTP 500 or curl 22 The requested URL returned error: 500
The server returned an internal error. During clone or push this often means the HTTP request size exceeded the client-side buffer limit. Increase the HTTP post buffer so larger requests can be sent:
git config http.postBuffer 524288000
This sets the buffer to 500 MiB for this repository. Retry your clone or push. If the error continues, contact Harness Support.
Unexpected disconnect while reading sideband packet
Error: unexpected disconnect while reading sideband packet
The connection dropped while Git was receiving data (for example during a long clone or large transfer). Common causes include network instability, timeouts, or server-side limits.
Contact Harness Support to diagnose. If you work with large files (1 GiB or more), use Git Large File Storage (LFS) or contact Support for options.
Large files (+4 GiB) on Git for Windows
Clone or push of files larger than 4 GiB may fail or not complete when using Git for Windows (the transfer can stop or the file may not be fully sent). For further details, see the Git for Windows large-file issue.
What to do:
- Use Windows Subsystem for Linux (WSL) and run Git from a Linux environment, or
- Contact Harness Support for alternatives such as Harness Artifact Registry for very large artifacts.