Skip to content

Commit 36ca13e

Browse files
authored
Merge pull request #334 from inbo/merge_conflict
tutorial on solving merge conflict on GitHub.com
2 parents 59356d1 + 798ca43 commit 36ca13e

6 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 warns about a merge conflict.
13+
A merge conflict occurs when one or more lines were altered in the base branch so that a merge conflict arises in the feature 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 webpage highlights them by a red vertical line.
22+
Every merge conflict inserts three delimiters:
23+
24+
1. `<<<<<< feature 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 of the branches within the conflict.
32+
Potentially you need to keep a mix of both.
33+
Don't forget to also delete the three delimiters when you're ready.
34+
Should fixing the merge conflict be more complicated, then you probably better fix them via the [command line](../git_conflict/index.html).
35+
In our example we solved the conflict by keeping the content of the feature branch.
36+
37+
![Solved merge conflict on GitHub.com](merge-conflict-3.png)
38+
39+
Once you have fixed all merge conflicts, go to the top of the page.
40+
There hit the `Mark as resolved` button.
41+
42+
![Mark a merge conflict as resolved on GitHub.com](merge-conflict-4.png)
43+
44+
Finally you store the fixes in a new commit by hitting the `Commit merge` button.
45+
46+
![Commit a merge conflict on GitHub.com](merge-conflict-5.png)
47+
19.1 KB
Loading
44.1 KB
Loading
39.2 KB
Loading
5.17 KB
Loading
3.76 KB
Loading

0 commit comments

Comments
 (0)