> 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/harness-platform/3.0/harness-platform-resources/connectors/code-repositories/connect-to-code-repo.md).

# Connect to a Git repository

Harness code repository connectors connect your Harness account with your Git SCM provider. Connectors are used to pull code and other important files, such as Helm charts, Kubernetes manifests, and Terraform scripts, from your Git repos.

You can add code repo connectors at the account, organization, or project [scopes](/harness-platform/3.0/harness-platform-resources/platform-access-control.md#permissions-hierarchy-scopes). This topic assumes you're adding connectors at the project scope, but the connector configuration is the same for any scope.

### Code repo connector permissions and access <a href="#code-repo-connector-permissions-and-access" id="code-repo-connector-permissions-and-access"></a>

Review the following important information about code repo connectors.

#### Git provider account permissions <a href="#git-provider-account-permissions" id="git-provider-account-permissions"></a>

When you create a code repo connector, you provide credentials for authentication and authorization, such as a username and password, token, or another authentication method. The credentials allow the connector to take actions in your Git provider, such as cloning repositories or reading information in pull requests. Therefore, the credentials provided to the connector must have the necessary permissions to perform the actions required by the connector's functionality.

In general, the account/token specified in the connector configuration must have the same permissions that an equivalent user account would need to perform the same actions that the connector will take. **When creating a personal access token, the user account you use to create the token must have the required permissions or higher, such as a repo admin.**

For example, if the connector needs to clone repositories, the credentials provided in the connector must allow reading and cloning repositories. To create a token with sufficient permissions, you must use a user account that has sufficient (or higher) permissions. Similarly, if the connector needs to pull manifests from a repo, then the credentials provided in the connector must have `read repo` (or equivalent) permissions in your Git provider.

Some connectors require that you use an account with higher permissions, such as an admin account. For more details, refer to the configuration details for the specific connector that you're configuring. For permissions in the Harness Git Experience, go to [Source Code Manager Settings](/harness-ai/use-harness-platform/connectors/code-repositories/ref-source-repo-provider/source-code-manager-settings.md).

#### Using SSH key authentication <a href="#using-ssh-key-authentication" id="using-ssh-key-authentication"></a>

If your code repo connector uses SSH Key authentication, the SSH Key is stored as a [Harness SSH credential secret](/harness-ai/use-harness-platform/secrets/add-use-ssh-secrets.md), and the SSH credential's **Username** must be `git`.

#### Using connectors with Harness Cloud build infrastructure <a href="#using-connectors-with-harness-cloud-build-infrastructure" id="using-connectors-with-harness-cloud-build-infrastructure"></a>

If you plan to use a connector with [Harness Cloud build infrastructure](/continuous-integration/use-harness-ci/use-harness-ci/set-up-build-infrastructure/use-harness-cloud-build-infrastructure.md), the **Connectivity Mode** must be **Connect through Harness Platform**.

### Connect to AWS CodeCommit <a href="#connect-to-aws-codecommit" id="connect-to-aws-codecommit"></a>

You can use either an AWS CodeCommit connector or the platform-agnostic Git connector to connect to AWS CodeCommit repos.

Regardless of which connector you choose, the IAM account you use to connect to CodeCommit must have the following policies:

* **AWSCodeCommitPowerUser**
* **DescribeRegions**

The [DescribeRegions](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRegions.html) action is required for all AWS connections, regardless of what AWS resource you use with Harness.

For instructions on setting up the IAM user for CodeCommit connections, go to the following AWS documentation:

* [Setup for HTTPS users using Git credentials from AWS](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html)
* [AWS managed policies for CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/security-iam-awsmanpol.html)

{% tabs %}
{% tab title="AWS CodeCommit connector" %}

1. In your Harness project, select **Connectors** under **Project Setup**.
2. Select **New Connector** and select **AWS CodeCommit** under **Code Repositories**.
3. Configure the [AWS CodeCommit connector settings](/harness-ai/use-harness-platform/connectors/cloud-providers/ref-cloud-providers/aws-connector-settings-reference.md):
   * Enter a **Name**.
   * Select **Repository** to connect to one repo or select **Region** to connect to an entire AWS region. Selecting **Region** lets you use one connector for all repos in that region.
   * If you selected **Repository**, enter the **AWS CodeCommit Repository URL**, such as `https://git-codecommit.us-west-2.amazonaws.com/v1/repos/doc-text`. You can get this URL from your CodeCommit repo by using its **Clone URL** menu and selecting **Clone HTTPS**.
   * If you selected **Region**, provide the name of a repo that Harness can use to test the connection.
   * In **Access Key** and **Secret Key**, enter the IAM user's access key and secret key, respectively. Use [Encrypted text secrets](/harness-ai/use-harness-platform/secrets/add-use-text-secrets.md) to store keys.
4. After the connection test runs, select **Finish** to save the connector.
   {% endtab %}

{% tab title="Platform-agnostic Git connector" %}
You can connect to CodeCommit [using the Harness platform-agnostic Git connector](#use-the-platform-agnostic-git-connector), instead of the AWS CodeCommit connector.

With the generic Git connector, you must use a username and password for the IAM user, instead of an access key and secret key.

1. On the configuration page for the IAM User, select **Security credentials**, and then generate credentials in **HTTPS Git credentials for AWS CodeCommit**.
2. In your Harness project, select **Connectors** under **Project Setup**.
3. Select **New Connector** and select **Git** under **Code Repositories**.
4. Configure the [Git connector settings](/harness-ai/use-harness-platform/connectors/code-repositories/ref-source-repo-provider/git-connector-settings-reference.md):
   * Enter a **Name**.
   * Select **Repository** for the **URL Type**.
   * Select **HTTP** for the **Connection Type**.
   * In **Git Repository URL**, enter the AWS CodeCommit repository URL, such as `https://git-codecommit.us-west-2.amazonaws.com/v1/repos/doc-text`. You can get this URL from your CodeCommit repo by using its **Clone URL** menu and selecting **Clone HTTPS**.
   * In **Username** and **Password**, enter the username and password that you generated for the IAM user. Use an [Encrypted text secret](/harness-ai/use-harness-platform/secrets/add-use-text-secrets.md) to store the password.
5. After the connection test runs, select **Finish** to save the connector.
   {% endtab %}
   {% endtabs %}

### Connect to Azure Repos <a href="#connect-to-azure-repos" id="connect-to-azure-repos"></a>

Azure Repos is a set of version control tools that you can use to manage your code. Azure Repos provide the following kinds of version control:

* Git: Distributed version control
* Team Foundation Version Control (TFVC): Centralized version control

For instructions, go to [Connect to Azure Repos](/harness-ai/use-harness-platform/connectors/code-repositories/connect-to-a-azure-repo.md).

### Connect to Bitbucket <a href="#connect-to-bitbucket" id="connect-to-bitbucket"></a>

Harness supports both Cloud and Data Center (On-Prem) versions of Bitbucket.

1. In your Harness project, select **Connectors** under **Project Setup**.
2. Select **New Connector**, and select **Bitbucket** under **Code Repositories**.
3. Configure the [Bitbucket connector settings](/harness-ai/use-harness-platform/connectors/code-repositories/ref-source-repo-provider/bitbucket-connector-settings-reference.md).
4. After the connection test runs, select **Finish** to save the connector.

### Connect to GitHub <a href="#connect-to-github" id="connect-to-github"></a>

1. In your Harness project, select **Connectors** under **Project Setup**.
2. Select **New Connector**, and select **GitHub** under **Code Repositories**.
3. Configure the [GitHub connector settings](/harness-ai/use-harness-platform/connectors/code-repositories/ref-source-repo-provider/git-hub-connector-settings-reference.md).

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Harness recommends <a href="/spaces/3F2TpHXhur2QtQnORSM9/pages/GdsoW3Rewajzx7sM7Ri2">using GitHub Apps with GitHub connectors</a> for <a href="https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#primary-rate-limit-for-github-app-installations">increased rate limits</a>.</p></div>
4. After the connection test runs, select **Finish** to save the connector.

### Connect to GitLab <a href="#connect-to-gitlab" id="connect-to-gitlab"></a>

1. In your Harness project, select **Connectors** under **Project Setup**.
2. Select **New Connector**, and select **GitLab** under **Code Repositories**.
3. Configure the [GitLab connector settings](/harness-ai/use-harness-platform/connectors/code-repositories/ref-source-repo-provider/git-lab-connector-settings-reference.md).
4. After the connection test runs, select **Finish** to save the connector.

### Use the platform-agnostic Git connector <a href="#use-the-platform-agnostic-git-connector" id="use-the-platform-agnostic-git-connector"></a>

If Harness doesn't have a dedicated code repo connector for your Git provider, or your configuration prevents you from using the platform-specific code repo connector, you can use the platform-agnostic Git connector.

1. In your Harness project, select **Connectors** under **Project Setup**.
2. Select **New Connector**, and select **Git** under **Code Repositories**.
3. Configure the [Git connector settings](/harness-ai/use-harness-platform/connectors/code-repositories/ref-source-repo-provider/git-connector-settings-reference.md).
4. After the connection test runs, select **Finish** to save the connector.

### Troubleshooting code repo connectors <a href="#troubleshooting-code-repo-connectors" id="troubleshooting-code-repo-connectors"></a>

You might encounter these issues with code repo connectors. Additional connector-specific issues are described on the dedicated pages for each connector.

#### Network connection times out when fetching large repos <a href="#network-connection-times-out-when-fetching-large-repos" id="network-connection-times-out-when-fetching-large-repos"></a>

{% hint style="info" %}
Currently, the fetch optimization feature is behind the setting `Fetch files from Git using provider-specific APIs`, under Continuous Deployment section.
{% endhint %}

Harness performs a `git clone` to fetch files. When fetching very large repositories, the network connection can time out. With fetch optimization enabled, Harness uses provider-specific APIs to improve performance when fetching very large repos.

{% hint style="info" %}
**OPTIMIZED FETCHING FOR GITHUB ORGS WITH SAML**

If the setting `Fetch files from Git using provider-specific APIs` is enabled, and your GitHub organization has SAML enabled, the token must be SAML-authorized to access the organization, even if the repository is public. For more information, go to the GitHub documentation on [GitHub authentication with SAML single sign-on](https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/about-authentication-with-saml-single-sign-on).
{% endhint %}

#### Pipeline status updates aren't sent to PRs <a href="#pipeline-status-updates-arent-sent-to-prs" id="pipeline-status-updates-arent-sent-to-prs"></a>

Harness uses the pipeline's codebase connector to send status updates to PRs in your Git provider. Check the pipeline's [codebase configuration](/continuous-integration/use-harness-ci/use-harness-ci/codebase-configuration/create-and-configure-a-codebase.md) to confirm that it has a default codebase configuration and that it is using the correct code repo connector.

#### Connection tests fail due to network restrictions <a href="#connection-tests-fail-due-to-network-restrictions" id="connection-tests-fail-due-to-network-restrictions"></a>

If your connector connection tests (preflight checks) fail due to network restrictions, split DNS configurations, proxy setups, or restrictive firewall policies, but you know the connector will work at runtime, you can configure Harness to skip the connection validation.

To skip connector preflight checks, you need both:

1. **Account-level feature flag enabled**: Contact [Harness Support](mailto:support@harness.io) to enable the `CI_IGNORE_TEST_CONNECTION` feature flag for your account.
2. **Connector YAML configuration**: Add `ignoreTestConnection: true` to your connector's YAML configuration.

When both the feature flag and YAML property are enabled, connection tests will always return as "Successful" without performing actual connectivity validation.

For more information and an example configuration, go to [Create a connector using YAML](/harness-ai/use-harness-platform/connectors/create-a-connector-using-yaml.md#optional-skip-connector-preflight-checks).

{% hint style="warning" %}
Use this feature carefully. Skipping connection tests means Harness won't validate whether the connector credentials are correct or if the remote service is accessible. Only use this when you're certain the connector will work at runtime despite failing preflight checks.
{% endhint %}
