

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Conflicting Changes
incomplete
2: Merge Conflicts
incomplete
3: Merge
incomplete
4: Edit the File
incomplete
5: Resolution
incomplete
6: Conflict Quiz
incomplete
7: Back to Main
incomplete
8: Back to Main
incomplete
9: Ours and Theirs
incomplete
10: Multi-conflict
incomplete
11: Checkout Conflict
incomplete
12: No Merge Commits
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
A merge conflict occurs when two commits modify the same line and Git can't automatically decide which change to keep and which change to discard.
Consider the following commit history:
C feature
/
A - B main
The main branch has a file with these lines:
package main
func isNice(num int) bool {
return num == 69 // commit B changed this line
}
While feature has:
package main
func isNice(num int) bool {
return num == 420 // commit C changed this line
}
If we merge feature into main, Git will detect that the return line was changed in both branches independently: which creates a conflict.
When a conflict happens (usually as the result of a merge or rebase) Git will prompt you to manually decide which change to keep. It's okay when the same line is modified in one commit, and then again in a later commit. The problem arises when the same line is modified in two commits that aren't in a parent-child relationship.