> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up Git v2 with GitHub

> Turn on Git v2 for an Omni model that is connected to a GitHub repository: add the Pull request and Push webhook events and turn on the setting.

> [!NOTE]
>
> Git v2 is available for GitHub repositories. To have Git v2 turned on for your organization, reach out to Omni support.

In this guide, you'll turn on [Git v2](https://docs.omni.co/integrations/git/v2) for an Omni model that is connected to a GitHub repository.

## Requirements

To follow the steps in this guide, you'll need:

* [**Connection Admin permissions**](https://docs.omni.co/administration/users/permissions.md) for the Omni model, which are required to change the model's git settings
* **A GitHub repository connected to the model** with one of these authentication methods:
  * [GitHub App](https://docs.omni.co/integrations/git/setup/github.md#launch-the-omni-github-app-installation-flow)
  * [HTTPS token](https://docs.omni.co/integrations/git/setup/github.md#create-a-github-fine-grained-personal-access-token). In addition to the permissions in the linked steps, the token needs **Commit statuses**: Read and write.
* **Permissions in GitHub that allow you to:**
  * Add webhooks to the repository

## Set up Git v2

### 1. Open the model's git settings

1. In Omni, click **Develop** in the [sidebar](https://docs.omni.co/administration/settings/sidebar.md) and open the model.
2. In the model IDE, click **Model > Advanced > Git settings**. You can also click the **Settings** icon in the left navigation, then click **Git Settings**.

Keep this page open. You'll copy values from it in the next step.

### 2. Add the Pull request and Push webhook events

Git v2 needs two events from GitHub:

* **Pull request** - Omni runs checks when a pull request is opened or updated, and updates the shared model when a pull request is merged.
* **Push** - Omni updates the shared model when someone commits directly to the model's base branch.

1. In GitHub, open the repository's **Settings** page.
2. Click **Webhooks**, located in the **Code, planning, and automation** section of the sidebar.
3. If the repository already has a webhook for Omni, click **Edit** next to it. Otherwise, click **Add webhook** and fill in the fields as follows:
   * **Payload URL** - From the Omni **Git settings** page, copy the **Payload URL** and paste it into this field.
   * **Content type** - Select the **application/json** option.
   * **Secret** - From the Omni **Git settings** page, copy the **Webhook secret** and paste it into this field.
   * **SSL verification** - Omni recommends leaving SSL verification enabled.
4. In the **Which events would you like to trigger this webhook?** section:
   1. Click **Let me select individual events**.
   2. Select the **Pull request** and **Push** events.
5. Click **Add webhook**, or **Update webhook** if you edited an existing one.

### 3. Turn on Git v2

On the Omni **Git settings** page, go to the **Git integration version** section and turn on **Use v2 Git integration**.

The setting applies to one model. If several models share a repository, turn it on for each model.

The build and validation checks need an Omni branch for the pull request. To have Omni create a branch for every pull request, turn on [Always create branches](https://docs.omni.co/integrations/git/settings.md#always-create-branches).

### 4. Optional: Add a configuration file

To change the severity of a [pull request check](https://docs.omni.co/integrations/git/v2/checks.md), add a file at `.omni/config.yaml` on the repository's [base branch](https://docs.omni.co/integrations/git/settings.md#base-branch). If the repository doesn't have the file, Omni runs the checks with these default settings:

```yaml title=".omni/config.yaml" theme={null}
version: 1
checks:
  build: error
  sync: warn
  validation: warn
```

With the default settings, if a sync or validation check fails, Omni warns you in its comment, and the commit status passes.

To block merges on a failed check, see [Block merges on a failed check](https://docs.omni.co/integrations/git/v2/checks.md#block-merges-on-a-failed-check). For every setting, see [Configuration file](https://docs.omni.co/integrations/git/v2/config-file.md).

### 5. Confirm the setup

Open a pull request that changes a model file. Omni posts a `Model: <model_path>` commit status and a comment on the pull request.

## Next steps

* [Pull request checks](https://docs.omni.co/integrations/git/v2/checks.md)
* [Configuration file](https://docs.omni.co/integrations/git/v2/config-file.md)
* [Git v2 settings](https://docs.omni.co/integrations/git/v2/settings.md)
* [Troubleshooting Git v2](https://docs.omni.co/integrations/git/v2/troubleshooting.md)
