> For the complete documentation index, see [llms.txt](https://docs.flosum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flosum.com/devops/pull-requests/pull-request-process/resolving-pull-request-conflicts.md).

# Resolving Pull Request Conflicts

{% hint style="warning" %}

#### Written for the Old UI

This article was written for the old UI. The instructions are still usable, but the screenshots are outdated. In some cases, items referenced in the instructions have moved or changed. If you cannot find an item, see the [Where Did It Go](/devops/new-ui-ux-transition/where-did-it-go.md) article.
{% endhint %}

## ![](https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FG5ZbxX918xOHwbAwAJ4n%2FSummary2-Small-Icon.svg?alt=media\&token=da26a67f-ff7f-47b3-8669-06be960dc2d7) Overview

This article explains the reasons behind Pull Request conflicts and the common scenarios in which they occur. It also provides detailed, step-by-step instructions for reviewing and resolving these conflicts effectively.

### What causes a Pull Request conflict?

A Pull Request conflict can occur when two branches have commits that affect the same line of code, and the Pull Request is unable to automatically determine which line to preserve. To illustrate how this can happen, see the diagram below.

<div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2F3eIOztucBaSOKuGON5bV%2FPull%20Request%20Conflict%20-%20Figure%201.png?alt=media&amp;token=6e11e440-bc32-4289-86b2-e757c420a2e0" alt="" width="563"><figcaption></figcaption></figure></div>

In this example, **branch\_b** is created from **branch\_a**. Next, a change affecting the *myName* function is committed to **branch\_b**, and a different change to the function is committed to **branch\_a**. When a Pull Request is created to merge **branch\_b** into **branch\_a**, the pull request detects that the same line of code has changed in both branches, resulting in a conflict. In the following section, you will see two different options for resolving the conflict.

### How to resolve a Pull Request conflict?

When a Pull Request encounters a conflict, you can resolve it by either retaining or overwriting the target's changes. For multiple conflicts, address each one separately using the most appropriate method; it's okay to use different approaches for different conflicts.

<details>

<summary>Retain Target Changes</summary>

To resolve conflicts using this method, commit the conflicting lines from the **target** branch into the **source** branch. See the diagram for an illustration, and refer to the step-by-step instructions provided in the [#retain-target-changes-1](#retain-target-changes-1 "mention") section below.

{% hint style="info" %}
This method uses the **Resolve Conflicts** function in a Pull Request to automatically commit the changes to the source branch.
{% endhint %}

<figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FfdBOyMKCsalcBawvM7ED%2FPull%20Request%20Conflict%20-%20Figure%202.png?alt=media&amp;token=6e3f9324-daa3-468b-9e27-8c0376830794" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>Overwrite Target Changes</summary>

To resolve conflicts using this method, commit the conflicting lines from the **source** branch into the **target** branch. See the diagram for an illustration, and refer to the step-by-step instructions provided in the [#overwrite-target-changes-1](#overwrite-target-changes-1 "mention") section below.

{% hint style="info" %}
This method requires you to manually commit the changes from the **source** branch into the **target** branch.
{% endhint %}

<figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FVaZecNF0HTB21tlT1oKW%2FPull%20Request%20Conflict%20-%20Figure%203.png?alt=media&amp;token=1c8af0e0-97e7-46dd-a428-1f4b66e1e341" alt=""><figcaption></figcaption></figure>

</details>

## Resolving Conflicts

{% stepper %}
{% step %}

### Pull Request Conflicts

When a Pull Request is created, a conflict check is run initially. If any conflicts between the **Target** and **Source** branches are found, a warning will be displayed, and you must resolve the conflicts before the Pull Request can be merged.

<div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FK9JALbdKadbvEFqPe00z%2FResolvingPullRequestConflicts-S01-01.png?alt=media&amp;token=4973d672-8444-46fe-8e35-150acd351ba8" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

### Review Conflicts

1. Click **Resolve conflicts**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2F8pYu7mdbTdXEXva8Zf23%2FResolvingPullRequestConflicts-S02-01.png?alt=media&amp;token=a13bbbd4-870d-4895-b5d7-17598f9f799b" alt="" width="563"><figcaption></figcaption></figure></div>
2. Click a component to view the conflicts.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2Fhd7mmwFjgbQRTVwIIkud%2FResolvingPullRequestConflicts-S02-02.png?alt=media&amp;token=c2864009-da37-4116-b9fa-4b2ffbbb46f1" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="warning" %}
All components need to be reviewed and resolved.
{% endhint %}

3. Review the conflicting code in the component and determine how to resolve the conflict.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FJOCmqXNWisObvgSQHKGr%2FResolvingPullRequestConflicts-S02-03.png?alt=media&amp;token=9b9f9a30-b3e2-40ea-948c-5dccc2b3fd54" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
See the [#what-causes-a-pull-request-conflict](#what-causes-a-pull-request-conflict "mention") section above for an explanation of Pull Request conflicts.
{% endhint %}

4. There are two ways to resolve a Pull Request conflict. See the following sections for instructions about how to perform each.
   1. **Retain Target Changes**: This method keeps the target's code by committing the conflicting lines from the **target** branch into the **source** branch.
   2. **Overwrite Target Changes**: This method keeps the source's code by committing the conflicting lines from the **source** branch to the **target** branch.

{% hint style="info" %}
For multiple conflicts, address each one separately using the most appropriate method; it's okay to use different approaches for different conflicts.
{% endhint %}
{% endstep %}

{% step %}

### Retain Target Changes

This method uses the **Resolve conflicts** feature built into a Pull Request.

1. Click a component with conflicts to resolve.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FnhVr1raQZTvAcw9WOc0C%2FResolvingPullRequestConflicts-S03-01.png?alt=media&amp;token=5b31efc1-49e1-440a-bc96-6b814a4b2486" alt="" width="563"><figcaption></figcaption></figure></div>
2. Click **Accept all** to retain all lines, or click the **Right** **Arrow** for each line to retain. This copies the selected line from the target branch to the source branch.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FBg7oBwXUrHGZ38xWlH0q%2FResolvingPullRequestConflicts-S03-02.png?alt=media&amp;token=9daa3a07-3fab-4016-b589-231f4b0e2143" alt="" width="563"><figcaption></figcaption></figure></div>
3. Once all necessary changes have been made to the source branch, click **Resolve**. This marks a component as **Resolved** so you can keep track of your changes.
4. Click **Back**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FaOEtG2UOuvfX4mfiHKPf%2FResolvingPullRequestConflicts-S03-03.png?alt=media&amp;token=d831374c-a137-4036-a4c3-ff853431d6e4" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Repeat this process for all components with conflicts.
{% endhint %}

5. Once all components are marked as **Resolved**, click **Resolve conflicts**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FSmVZ0MxD4NguSwB7dtNl%2FResolvingPullRequestConflicts-S03-04.png?alt=media&amp;token=40f79012-9e17-4f74-b4aa-f8eeef229c93" alt="" width="563"><figcaption></figcaption></figure></div>
6. Enter a **Commit message**.
7. Click **Resolve**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FaOXu8XK1s9ePPohbfp9D%2FResolvingPullRequestConflicts-S03-05.png?alt=media&amp;token=4ae6eb1f-e6b8-4bc9-81d1-00a5e20eb8d8" alt="" width="375"><figcaption></figcaption></figure></div>
8. After resolving the conflicts, the Pull Request will check for conflicts again.
9. If there are no more conflicts, the Pull Request message will be green and state "This branch is able to merge".

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2F4DbE815qPh7WKEA1uXtk%2FResolvingPullRequestConflicts-S03-06.png?alt=media&amp;token=99b78d90-5278-478b-8182-3c5ab325a9eb" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
If conflicts persist in the Pull Request, review and resolve them. Repeat until all issues are resolved.
{% endhint %}
{% endstep %}

{% step %}

### Overwrite Target Changes

This method requires manually editing and committing changes to the target branch.

{% hint style="info" %}
To make it easier to resolve conflicts when overwriting changes in the target branch, note the specific lines and components causing conflicts as you review the Pull Request.
{% endhint %}

1. Click **Code** from the left sidebar menu.
2. Click the **target** branch of the Pull Request.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FVdGI0XqpcphJPuoqXMfn%2FResolvingPullRequestConflicts-S04-01.png?alt=media&amp;token=30f3e50f-f1aa-41fa-b814-9c109f8342b7" alt="" width="563"><figcaption></figcaption></figure></div>
3. Click the **Three Vertical** dots at the right end of a component with conflicts in the Pull Request.
4. Click **Edit**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2F5g5ClKMeHBcegHcwiUOW%2FResolvingPullRequestConflicts-S04-02.png?alt=media&amp;token=c2446acd-0011-498a-aa3a-f5277d191ed5" alt="" width="563"><figcaption></figcaption></figure></div>
5. Edit the conflicting line or lines of code to match the **source** branch.
6. Click **Commit changes**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FwzKDv4loReHxkn6mJTem%2FResolvingPullRequestConflicts-S04-04.png?alt=media&amp;token=3e5c1d17-4228-478e-95e1-5823bd154d67" alt="" width="563"><figcaption></figcaption></figure></div>
7. Enter a **Commit message**.
8. Click **Commit**.

   <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2Fs8v4c5oagdYwOQ7cMc86%2FResolvingPullRequestConflicts-S04-05.png?alt=media&amp;token=bb1bd0af-51f9-42e6-abf0-1ffb2ee13dbc" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Repeat this process for all components with conflicts.
{% endhint %}

9. Once all components with conflicts are edited to match the **source** branch, return to the Pull Request.
10. Click **Pull requests** from the left sidebar menu.
11. Click the Pull Request to check if all conflicts are resolved.

    <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2Fp64mN9HFNBOa33H6VsOs%2FResolvingPullRequestConflicts-S04-06.png?alt=media&amp;token=3866aa56-1b59-49de-b255-a48b7fb68f1a" alt="" width="563"><figcaption></figcaption></figure></div>
12. If there are no more conflicts, the Pull Request message will be green and state "This branch is able to merge".

    <div align="left"><figure><img src="https://1800549522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FPLcM3AH2yPcm2RXGsPDY%2FResolvingPullRequestConflicts-S04-07.png?alt=media&amp;token=857898d0-5d1b-4374-b540-6a7729b44b23" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
If conflicts persist in the Pull Request, review and resolve them. Repeat until all issues are resolved.
{% endhint %}
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flosum.com/devops/pull-requests/pull-request-process/resolving-pull-request-conflicts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
