Skip to main content

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 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 tool to seamlessly migrate all data from other Git SCM providers. For details, refer to the Migrate repositories section.

Migrate repositories

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 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

  1. In the Harness Code module, make sure you are at the scope 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:

  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.

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.

Work with repositories

After importing a repository, you can: