FirstHack Learn
Log in Sign up free
Lessons in this course 0/6 All courses Git and GitHub for Students

First year

Progress0 / 6 lessons
  1. 1. What version control actually solves
  2. 2. init, add, commit: what a commit really is
  3. 3. Branches and merging
  4. 4. Remotes, push, pull and the rejected-push error
  5. 5. Merge conflicts, resolved step by step
  6. 6. Pull requests, .gitignore and a good README

Courses › Git and GitHub for Students

Merge conflicts, resolved step by step

What those angle-bracket markers mean and exactly how to clear them.

11 min read · Lesson 5 of 6 · Pro

Why conflicts happen

Git merges automatically when two branches changed different lines. It stops and asks you when two branches changed the same lines of the same file. It has no way to know which version is right. That judgement is yours.

A conflict is not a failure. It is Git refusing to guess.

Create one on purpose

Do this in a scratch folder. Learning conflicts under exam pressure is the wrong time.

BASH
mkdir conflict-demo
cd conflict-demo
git init
echo "print('welcome to the app')" > main.py
git add main.py
git commit -m "Add welcome message"
The rest of this lesson is Pro

The free lessons of Git and GitHub for Students finish what they start — read those first if you have not. This one goes further, and it is part of the paid half.

A pass opens the paid lessons of every course, the mock test papers and the company-wise series. It ends on its own date; nothing renews by itself.

Get a pass — from ₹29 for 7 days

Already bought one? Log in.