> 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/use-harness-platform/connectors/code-repositories/add-a-git-connector.md).

# Add a Git connector

Add a Git connector so Harness pipelines can pull code and other files from any Git-compatible provider that does not have a dedicated connector.

The Git connector is the Harness platform-agnostic code repository connector. Git is the underlying distributed version control system used by GitHub, GitLab, Bitbucket, Azure Repos, and many other providers. The Git connector uses standard Git commands to connect securely over the web or SSH. It works with any provider that exposes a standard Git remote, including self-hosted Git servers, various SaaS providers, and services like AWS CodeCommit, without requiring a provider-specific integration.

Go to [Overview](https://developer.harness.io/harness-platform/use-harness-platform/connectors/code-repositories/code-repositories-connectors-overview.md) for information about all code repos connectors, such as scopes, permissions and connectivity modes.

## What you will learn from this topic

* How to [add a Git connector](#add-a-git-connector) to a Harness project so pipelines can pull code from any Git-compatible provider.

***

## When to use the Git connector instead of a dedicated connector

Use the Git connector when:

* Harness does not offer a dedicated connector for your Git provider.
* Your Git provider is API-compatible with plain Git over HTTP or SSH, and you do not need provider-specific features such as PR status checks tied to a dedicated connector type.

{% hint style="info" %}
**Use a dedicated connector if it exists**

If a dedicated connector exists for your provider (Azure Repos, Bitbucket, GitHub, or GitLab), Harness recommends using it instead. Dedicated connectors support provider-specific features such as GitHub Apps, Azure Repos API access, and provider-aware webhooks that the Git connector does not.
{% endhint %}

***

## Before you begin

Before you create a Git connector, ensure you have:

* A Git repository reachable over HTTP(S) or SSH.
* A username and password or token, or an SSH key, with permission to read (and, if needed, clone) the repository.
* Permission to create connectors in Harness.

***

## Add a Git connector

You can add a Git connector at the project, org, or account scope. This procedure covers the project scope, and the process is the same for org and account.

You can also add a Git connector directly when configuring a codebase or artifact source in a pipeline or service.

Follow the interactive guide below for a step-by-step walkthrough:

{% embed url="<https://app.arcade.software/share/xqOQRbAZVZWHCXZjSpsE>" %}
Add a platform-agnostic Git connector in Harness
{% endembed %}

Perform the following steps to add a Git connector:

1. Open your Harness project.
2. In **Project Settings**, select **Connectors**.
3. Click **New Connector**, then select **Git**. The Git Connector settings appear.

### Overview

Configure the identity fields for the connector.

In **Name**, enter a name for the connector. Optionally, add a description and tags. Click **Continue**.

### Details

Configure the following details:

1. For **URL Type**, select one of:
   * **Account**: Connect to an entire Git account or organization. The connector can be used for every repository in that account.
   * **Repository**: Connect to a single Git repository.
2. For **Connection Type**, select **HTTP** or **SSH**.
3. Enter the **Git Account URL** or **Git Repository URL**, depending on the URL Type you selected. The format depends on your Git provider and Connection Type. For example:

   * HTTP format: `https://<git-provider>.com/USERNAME/REPO_NAME`
   * SSH format: `git@<git-provider>.com:USERNAME/REPO_NAME`

   For SSH, the URL is valid only if it starts with the prefix `git@`.
4. If you selected **Account** for URL Type, enter a **Test Repository**. Harness uses this repository only to validate the connection. You specify the actual repository to use when you reference the connector in a pipeline.
5. Click **Continue**.

### Credentials

Configure the credentials based on the connection type you selected:

* If you selected **HTTP**:
  * **Username**: Enter the username for the account. You can use plaintext or a [Harness encrypted text secret](https://developer.harness.io/harness-platform/use-harness-platform/secrets/add-use-text-secrets.md).
  * **Password**: Select or create a new [Harness encrypted text secret](https://developer.harness.io/harness-platform/use-harness-platform/secrets/add-use-text-secrets.md) to store your password, personal access token, or app password, depending on your provider.
* If you selected **SSH**:
  * Select or create a new [Harness SSH credential secret](https://developer.harness.io/harness-platform/use-harness-platform/secrets/add-use-ssh-secrets.md) to store your SSH key. The SSH credential's **Username** must be `git`.

Go to [Git connector settings reference](https://developer.harness.io/harness-platform/use-harness-platform/connectors/code-repositories/add-a-git-connector/git-connector-settings-reference.md) for detailed information on Git connection settings.

### Select Connectivity Mode

Select how Harness connects with your Git provider:

* **Connect through Harness Platform**: Use a direct, secure communication between Harness and your Git provider. All credentials are encrypted and stored in the Secret Manager configured in Harness. This connectivity mode is required for [Harness Cloud build infrastructure](https://developer.harness.io/docs/continuous-integration/use-ci/set-up-build-infrastructure/use-harness-cloud-build-infrastructure/).
* **Connect through a Harness Delegate**: Harness communicates with your Git provider through a Harness Delegate you install in your environment, behind your corporate firewall.

### Delegates Setup

If you selected **Connect through a Harness Delegate**, select either:

* **Use any available Delegate**: Harness selects an available delegate at runtime.
* **Only use Delegates with all of the following tags**: Select specific delegates for Harness to use with this connector.

Click **Save and Continue**.

### Test Connection

Click **Finish** after the connection test succeeds. The connector is listed in **Connectors**.

If the connection test fails:

* Confirm the repository or account URL matches the format for your selected Connection Type. HTTP URLs must start with `https://`, and SSH URLs must start with `git@`.
* Confirm the username and password, token, or SSH key has the required permissions on the repository.
* If you are connecting through a delegate, confirm the delegate can reach your Git server over the network, and that split DNS, proxy, or firewall configurations are not blocking the connection.

***

## Sample YAML

The following example shows a YAML for the Git connector created in this guide.

<details>

<summary>YAML - Git connector</summary>

```yaml
connector:
  name: satyam-git-connector # Replace with a name for your connector
  identifier: satyamgitconnector # Replace with a unique identifier
  description: ""
  accountIdentifier: your-account-identifier # Replace with your Harness account identifier
  orgIdentifier: default # Replace with your organization identifier, or remove for account scope
  projectIdentifier: your-project-identifier # Replace with your project identifier, or remove for org/account scope
  type: Git
  spec:
    url: your-repo-url # Replace with your Git account or repository URL
    executeOnDelegate: false # Set to true if you selected Connect through a Harness Delegate
    proxy: false
    ignoreTestConnection: false # Set to true only to skip connector preflight checks
    type: Http # Use "Ssh" instead if you selected SSH as the Connection Type
    connectionType: Repo # Use "Account" instead if you selected Account as the URL Type
    spec:
      username: your-account-username # Replace with your username, or a Harness expression referencing a secret
      passwordRef: your-password # Replace with a reference to the Harness secret storing your password or token
```

</details>

For the full connector YAML schema, including how to skip connector preflight checks, go to [Create a connector using YAML](https://developer.harness.io/harness-platform/use-harness-platform/connectors/create-a-connector-using-yaml.md).

***

## Next steps

* [Use delegate selectors](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors.md): control which delegates can connect to this connector.
* [Add a secret manager](https://developer.harness.io/harness-platform/use-harness-platform/secrets/secrets-management.md): store connector credentials in a secret manager instead of the Harness built-in secret manager.
