|
| 1 | +--- |
| 2 | +title: "Handle Git conflicts via GitHub.Com" |
| 3 | +description: "How to handle git conflicts using the GitHub website" |
| 4 | +authors: [thierryo] |
| 5 | +date: 2024-04-17 |
| 6 | +categories: ["version control"] |
| 7 | +tags: ["git", "version control"] |
| 8 | +--- |
| 9 | + |
| 10 | +## Fix merge conflict with a pull request |
| 11 | + |
| 12 | +Sometimes a pull request warnings about a merge conflict. |
| 13 | +A merge conflict occurs when one or more lines were altered both in the base branch as in the issue branch. |
| 14 | +The warning looks like the image below. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +You can fix most merge conflicts in the browser. |
| 19 | +First push the `Resolve conflict` button in the warning. |
| 20 | +The website sends you to a page with a list of all merge conflicts. |
| 21 | +The website highlights them by the red vertical line with yellow background between the line numbers and the code. |
| 22 | +Every merge conflict inserts three delimiters. |
| 23 | + |
| 24 | +1. `<<<<<< issue branch name`: the start of the merge conflict |
| 25 | +1. `======`: the separator between the content of both branches |
| 26 | +1. `>>>>>> base branch name`: the end of the merge conflict |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +Fix the merge conflict by changing the source. |
| 31 | +Often you can fix it by simply deleting the content of one to the branches within the conflict. |
| 32 | +Potentially you need to keep a mix of both. |
| 33 | +Should fixing the merge conflict is more complicated, then you probably better should fix them via the [command line](index.html). |
| 34 | +In our example we solved the conflict by keeping the content of the issue branch. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +Once you fixed all merge conflict, go to the top of the page. |
| 39 | +There hit the `Mark as resolved` button. |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +Finally you store the fixes in a new commit by hitting the `Commit merge` button. |
| 44 | + |
| 45 | + |
| 46 | + |
0 commit comments