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

# Resolve conflicts

> When edits in Omni conflict with commits in git, Git v2 pushes Omni's version to a separate branch so you can resolve the conflict in a GitHub pull request.

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

On a repository that uses [Git v2](https://docs.omni.co/integrations/git/v2), an Omni branch and its pull request can each receive changes: you save edits in the model IDE, and other people push commits to the pull request branch in git. When both sides change the same part of a file, git can't merge them automatically. Omni then publishes its version to a separate branch, and you resolve the conflict in a GitHub pull request.

## How it works

### When a conflict happens

A conflict happens when both of the following are true:

* The Omni branch has edits that haven't been pushed to its pull request.
* The pull request branch has commits that you haven't pulled into the Omni branch, and those commits change the same parts of the files as your edits.

Omni finds the conflict when it merges your edits with the latest commit on the pull request branch. This happens when you [push or pull](https://docs.omni.co/integrations/git/v2/pull-and-push.md) in the model IDE, and when the branch header checks your saved edits against the pull request.

### What Omni does

Omni leaves the pull request branch as it is. To give you a place to resolve the conflict, Omni commits its version of the model to a separate branch in your repository, called the *conflict branch*. You resolve the conflict in a pull request from the conflict branch into your branch, called the *conflict pull request*.

### The conflict branch

The conflict branch is named `omni/<branch>/<commit>`:

* `<branch>` is the name of the Omni branch, which is also the pull request branch in git.
* `<commit>` is the first seven characters of the SHA of the last commit Omni pulled from that branch.

For example, a conflict on the `add-revenue-measures` branch creates a branch such as `omni/add-revenue-measures/3f9c2ab`.

The conflict branch starts at the last commit Omni pulled, so it contains the edits made in Omni since then. Each commit Omni makes includes an `Omni-Branch-Version` trailer, which Omni uses to recognize its own commits later.

### What you see in the model IDE

When Omni finds a conflict, the IDE shows one of these messages:

| Action | Message |
| - | - |
| Push | **Omni's version conflicts with git's changes.** |
| Pull | **Omni's edits conflict with the changes in git. Resolve them in git.** |

Until the conflict is resolved:

* The branch header shows a warning button named **Resolve conflicts**. Its tooltip reads **Your edits conflict with the pull request. Click to resolve.**
* The push and pull arrows open the same dialog as the **Resolve conflicts** button. Pushes and pulls are paused until the conflict is resolved.
* The branch's options menu has a **Resolve conflicts...** item.

Your edits stay in the Omni branch.

### What you see in GitHub

* **A new branch.** The conflict branch appears in the repository.
* **The sync check on your pull request.** On the next commit to your pull request, the [sync check](https://docs.omni.co/integrations/git/v2/checks.md) reports `Omni holds edits that conflict with this PR`. The end of the message depends on whether Omni has published its version:
  * **Published** - The message links to the conflict pull request, or to GitHub's page for opening it, with `resolve them in Omni's pull request`.
  * **Not published** - The message ends with `push them from the IDE to open a pull request that resolves them`.

Omni's checks run on your branch's pull request. Omni doesn't run checks on the conflict pull request.

## Resolve the conflict in GitHub

**1. Open the conflict dialog**

In the model IDE, click **Resolve conflicts** in the branch header. A dialog titled **Your edits conflict with the pull request** opens.

**2. Click Resolve in git**

Click **Resolve in git**. Omni pushes its current version to the conflict branch and opens GitHub in a new tab.

* If the conflict branch has an open pull request, that pull request opens.
* Otherwise, GitHub's page for opening a pull request opens. The base is your branch, the compare branch is the conflict branch, and the title and description are filled in. The title is `Merge Omni's edits to model '<model>' into <branch>`. Click **Create pull request**.

**3. Resolve the conflicts**

Resolve the conflicts on the pull request, either in GitHub's conflict editor or by committing a resolution to the conflict branch from your own git client. For each conflict, keep Omni's edit, git's change, or a combination.

**4. Merge the pull request**

Merge the conflict pull request into your branch. Merge commits and squash merges both work. You can delete the conflict branch after the merge.

## After the conflict pull request merges

When the conflict pull request merges, Omni records that git resolved the conflict. In the model IDE, the **Resolve conflicts** button goes away and the pull arrow shows that there are changes to pull.

To pull the resolution into the Omni branch:

**1. Pull the resolution**

In the model IDE, click the pull arrow. Omni pulls the resolved commit into the branch.

* If you saved no edits since the conflict, the IDE shows **The conflict was resolved in git, and the branch now matches the pull request.**
* If you saved more edits since the conflict, Omni merges those newer edits with the resolution. The IDE shows **Pulled the changes in git into Omni's edits; push to update the pull request.**

**2. Optional: Push newer edits**

If you saved edits after the conflict, click the push arrow to send them to the pull request.

If you push before you pull, Omni pulls the resolution first and then pushes your newer edits on top of it.

Omni keeps a resolution made in git. Every choice in the resolution stays in effect, so an edit from Omni that the resolution rejected stays rejected. If edits you saved after the conflict clash with the resolution, Omni reports a new conflict and you resolve it the same way.

## Other situations on the conflict branch

This table shows what Omni does when something else happens to the conflict branch or its pull request.

| What happens in git | What Omni does |
| - | - |
| The resolution is committed to the conflict branch, and the conflict pull request is still open | Omni blocks pushes until the pull request merges. A push shows **The conflict is resolved on its branch but not merged. Merge its pull request, or open one, then push again.** |
| The conflict pull request is squash merged | Omni recognizes the merge and applies the edits made in Omni since the conflict on top of the resolved commit. |
| The conflict branch is deleted when its pull request merges | Omni recognizes the resolution. |
| Someone adds their own commits on top of Omni's commit on the conflict branch | Omni treats those commits as changes from git and pulls them with the resolution. |
| The conflict pull request is closed without merging | The conflict stays unresolved. See [A conflict stays after the conflict pull request is closed](https://docs.omni.co/integrations/git/v2/troubleshooting.md#a-conflict-stays-after-the-conflict-pull-request-is-closed). |
| The conflict branch is rebased | Omni can't identify its own commit on the branch, so the conflict shows again on the next pull or push after the merge. |

## Next steps

* [Pull and push changes](https://docs.omni.co/integrations/git/v2/pull-and-push.md)
* [Pull request checks](https://docs.omni.co/integrations/git/v2/checks.md)
* [Git v2 best practices](https://docs.omni.co/integrations/git/v2/best-practices.md)
* [Troubleshooting Git v2](https://docs.omni.co/integrations/git/v2/troubleshooting.md)
