Session 2 — Exercises: Merge, Conflict, and Pull Request
Last updated on 2026-03-03 | Edit this page
Overview
In this session you will work in pairs to practise merging, resolving conflicts, and using pull requests.
Time frame: approximately 75 minutes of hands-on work.
Pair setup: decide who is Person A and who is Person B. You will both work on Person A’s repository.
Task 1: Mergeable Changes (No Conflict)
Level 1 — Edit different parts of the same file
-
Person A: add Person B as a collaborator on your
repository:
- Go to Settings → Collaborators → Add people and enter Person B’s GitHub username.
- Person B: accept the invitation (check your email or GitHub notifications), then clone Person A’s repository in GitHub Desktop.
- Both partners edit
README.mdat the same time, but in different sections:- Person A: add a “Hobbies” section at the top.
- Person B: add a “Favourite Books” section at the bottom.
- Person A: commit and push first.
- Person B: fetch, pull, then commit and push.
Checkpoint 1
Both changes appear in README.md on GitHub. Git merged
them automatically because they did not overlap.
Task 2: Create and Resolve a Merge Conflict
Level 1 — Intentional conflict
- Both partners open
README.md. - Both edit the same line (for example, change the first line of the “About Me” section to something different).
- Person A: commit and push.
- Person B: commit, then try to push — GitHub Desktop will tell you to pull first.
- Person B: pull. A merge conflict will appear.
Checkpoint 2
GitHub Desktop shows a conflict notification. The conflicted file contains markers like:
<<<<<<< HEAD
Person A's version of the line.
=======
Person B's version of the line.
>>>>>>> main
Level 2 — Resolve the conflict
- Open the conflicted file in your text editor.
- Decide which version to keep (or combine both).
- Remove the conflict markers
(
<<<<<<<,=======,>>>>>>>). - Save the file.
- In GitHub Desktop, mark the conflict as resolved and commit.
- Push the result.
Checkpoint 3
The repository now has a merge commit in its history. Both partners can pull and see the resolved file.
Task 3: Branch and Pull Request
Level 1 — Create a branch and commit
- In GitHub Desktop, click Current branch → New branch.
- Name it
add-resources(or another descriptive name). - Create a new file called
resources.mdwith a few useful links related to your studies or interests. - Commit with the message
Add resources file. - Click Publish branch to push it to GitHub.
Checkpoint 4
On GitHub, you can see the new branch in the branch dropdown. The
file resources.md exists only on the
add-resources branch, not on main.
Level 2 — Open a pull request
- GitHub Desktop shows a prompt Create Pull Request — click it.
- On GitHub, fill in a title and description for your PR.
- Click Create pull request.
- Ask your partner to review the PR:
- Go to the Files changed tab.
- Leave at least one comment.
- Approve the PR.
Checkpoint 5
The pull request page shows the conversation, file changes, and an approval.
Summary
By the end of this session you should have: