Skip to content

Commit a2cdec2

Browse files
committed
tutorial on solving merge conflict on GitHub.com
1 parent 59356d1 commit a2cdec2

6 files changed

Lines changed: 46 additions & 0 deletions

File tree

19.1 KB
Loading
44.1 KB
Loading
39.2 KB
Loading
5.17 KB
Loading
3.76 KB
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
![Message indicating a merge conflict on GitHub.com](merge-conflict-1.png)
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+
![Source with a merge conflict on GitHub.com](merge-conflict-2.png)
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+
![Solved merge conflict on GitHub.com](merge-conflict-3.png)
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+
![Mark a merge conflict as resolved on GitHub.com](merge-conflict-4.png)
42+
43+
Finally you store the fixes in a new commit by hitting the `Commit merge` button.
44+
45+
![Commit a merge conflict on GitHub.com](merge-conflict-5.png)
46+

0 commit comments

Comments
 (0)