> 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/use-harness-code/manage-repositories/import-repo.md).

# Import repositories

Repositories are where your code is stored. When developers make changes to code in a Harness Code repository, those changes are tracked with version control. Harness Code fosters collaboration and governance with code reviews, approvals, status checks, and more.

You can [create repositories directly in Harness Code](/code-repository/use-harness-code/manage-repositories/create-repo.md) or import repositories from other Git SCM providers, such as GitHub, GitLab, BitBucket, and more.

Harness Code Repository provides an easy option in the UI to import git repositories directly into your account. This feature only imports the Git data of the repository. You can also use the [`harness-migrate`](https://github.com/harness/harness-migrate) tool to seamlessly migrate all data from other Git SCM providers. For details, refer to the [Migrate repositories](#migrate-repositories) section.

*

### Migrate repositories <a href="#migrate-repositories" id="migrate-repositories"></a>

Harness provides a CLI tool to fully migrate git repositories as well as all meta data (including: Pull Requests, Labels, Webhooks, and Branch Rules) associated with those repositories. Refer to the [tool's open source repository](https://github.com/harness/harness-migrate) for all available options. The migration tool can be run from a command line on your laptop or directly on your self-hosted SCM server to avoid potential networking issues or firewall restrictions. You can also run the migration tool in a CI/CD pipeline to automate the migration process.

### Import repositories <a href="#import-repositories" id="import-repositories"></a>

1. In the Harness Code module, make sure you are at the [scope](/harness-ai/use-harness-platform/platform-access-control.md#permissions-hierarchy-scopes) where you want to import repositories.

   You can import repos at the account, organization, or project scope. For example, a repo imported at the account scope is available to the entire account, whereas a repo imported at the project scope is limited to that project.
2. Select **Repositories**, select the dropdown next to **New Repository**, and then select **Import Repository** or **Import Repositories**.
   * **Import Repository:** Import a single repository.
   * **Import Repositories:** Import all repositories in a GitHub/Gitea/Gogs organization, GitLab group, or Bitbucket project or workspace. Harness won't import repositories with conflicting names.
3. Select the **Git Provider**, such as GitHub or GitLab.
4. Depending on the provider, provide the administrative entity (**Organization**, **Project**, **Workspace**, or **Group**) and **Host URL** (if applicable) associated with your repository.
5. If you are importing a single repository, enter the name of the repository you want to import in **Repository**.

   Harness automatically populates the **Name** field based on the **Repository** field.

   If you want or need to change the repository name in Harness Code, you can change the **Name** field.

   Repository names in Harness Code can't contain the following strings:

   ```
   account.
   org.
   project.
   .git
   ```
6. If the repository or entity is private, select **Requires Authorization** and provide authorization credentials to access the repository.

   Permissions required for tokens depend on the provider, for example:

   * To import a Bitbucket Server repository, your [BitBucket Server personal access token](https://confluence.atlassian.com/bitbucketserver072/personal-access-tokens-1005335924.html) must have repository `Read` permissions.
   * To import a GitHub repository, your [GitHub classic personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic) must have `repo` and `read:org` [permissions](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps#available-scopes).
   * To import a GitLab repository, your [GitLab personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token) must have `read_api` and `read_repository` [scopes](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#personal-access-token-scopes).
   * To import an Azure DevOps repository, your [Azure DevOps personal access token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate) must have `Code (read)` scope.

{% hint style="info" %}
**RATE LIMITS DURING IMPORT**

Before the repository contents are fetched, Harness calls the source provider's API to resolve repository metadata (a single lookup, or paginated lists for **Import Repositories**). Every provider applies its own API rate limits.

* **Without authorization:** Requests are unauthenticated. On SaaS providers such as GitHub, GitLab, and Bitbucket Cloud, unauthenticated limits are typically tied to the **outbound IP address** and tend to be low, so this quota can be exhausted quickly when you import at scale. Self-hosted providers may not enforce a rate limit by default, or may apply different rules; check with your provider administrator or their documentation.
* **With authorization:** Requests use **your credential's rate limit**, which is usually much higher and independent of the unauthenticated IP quota.

If you see a rate limit error during import, repeat the import with **Requires Authorization** selected and provide a valid token for the source provider.

Harness recommends selecting **Requires Authorization** for any provider when you import many repositories, retry imports often, or import from large organizations, groups, projects, or workspaces. Use it for **private** repositories (required) and for **public** repositories when you want reliable imports that do not compete for the shared unauthenticated IP quota.
{% endhint %}

7. Select your preference for visibility (**Public** or **Private**).
8. Select **Import Repository** or **Import Repositories**.

You can observe in-progress imports on the **Repositories** page.

{% hint style="info" %}
**CANCEL IMPORT**

To cancel an in-progress import, locate the in-progress import on the **Repositories** page, select **More options** (⋮), and then select **Cancel Import**.
{% endhint %}

### Work with repositories <a href="#work-with-repositories" id="work-with-repositories"></a>

After importing a repository, you can:

* [Clone your repository.](/code-repository/use-harness-code/collaborate-and-develop/clone-repos.md)
* Create [branches](/code-repository/use-harness-code/collaborate-and-develop/branch.md) and [tags](/code-repository/use-harness-code/collaborate-and-develop/tag.md).
* [Commit changes](/code-repository/use-harness-code/collaborate-and-develop/commit.md) and [open pull requests](/code-repository/use-harness-code/pull-requests.md).
* [Configure branch rules](/code-repository/use-harness-code/manage-repositories/rules.md) and [access control](/code-repository/new-to-harness-code/onboarding-guide.md#manage-access).
* Use Harness Code repositories in your [Harness pipelines](/code-repository/use-harness-code/run-pipelines/codebase-from-harness-code.md).
* Set up [triggers](/code-repository/use-harness-code/run-pipelines/code-triggers.md) to automatically run pipelines based on activity in your Harness Code repositories.
* [Configure webhooks](/code-repository/use-harness-code/manage-repositories/webhooks.md) to integrate your repositories with third-party applications.
