Creating and Solving a Merge Conflict
A beginner-friendly GitHub collaboration activity (groups of 3 - 4)
GitHub exists to make collaboration easier. In this activity, you’ll practice a real team workflow: adding collaborators, making branches, opening pull requests, and intentionally resolving a merge conflict.
Recommended documentation (reference links)
- Adding collaborators: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-access-to-your-repository
- About branches: https://docs.github.com/en/get-started/using-git/about-branches
- About pull requests: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests
- About merge conflicts: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/about-merge-conflicts
Group setup
Form **groups of three - 4 **:
- 1 Repo Owner (Lead)
- 2 - 3 Collaborators
All pull requests will be made into the Repo Owner’s repository.
Part A — Repo Owner: Create the repository and add collaborators
Create a new repository (Repo Owner)
- Go to https://github.com and make sure you’re signed in.
- In the top-right corner, click the + icon. It is a few icons to the left of your profile picture.
- Click New repository.
- For Repository name, type:
Paired work - Set Visibility to Public.
- Check the box for Add a README file.
- Click Create repository.
Add the other two people as collaborators (Repo Owner)
- Inside your new repository, click the Settings tab.
- On the left sidebar, click Collaborators (sometimes it appears under “Access” / “Collaborators and teams” depending on UI).
- Click Add people.
- Type the first collaborator’s GitHub username (example:
MarthaMayWhovier). - Select the correct user from the dropdown.
- Click Add USERNAME to this repository.
- Repeat for the second collaborator.
- Learners must accept the email or web invitation (in notifications near the top right of each page) before they can push changes.
Part B — Collaborators: Accept the invitation (All non-owners)
Each collaborator must accept the invite before they can push branches.
- Go to https://github.com/notifications
- Look for a repository invitation.
- Click View invitation (or open the invitation notification).
- Click Accept invitation.
If you don’t see it:
- Ask the Repo Owner to confirm they entered the correct username.
- Refresh the page.
- Check email tied to your GitHub account (sometimes GitHub emails repo invites).
- Navigate directly to the repo and a banner should appear saying you’ve been invited.
Part C — Repo Owner: Create the “conflict bait” file on main
The Repo Owner will add a file directly to the main branch (this is intentional for the exercise).
Open the GitHub web editor
- Go to the main page of your repository (click the Code tab if needed).
- Press the period key on your keyboard:
.- This opens the GitHub web editor (looks similar to VS Code in the browser).
Tip: If pressing
.doesn’t work, make sure you clicked somewhere on the page first, and that your cursor isn’t inside a text field. You can also navigate to it by replacing thecomin your repo url withdev. - https://www.github.com/besteechur/paired_work is the url for the GitHub repo - https://www.github.dev/besteechur/paired_work is the url for the web editor
Create a new file named lets_make_a_conflict.md
- In the left file sidebar, look for an option like New File (or use the file explorer menu).
- Name the file,
lets_make_a_conflict.md - Paste or type the following template into the file (including blank lines):
YOUR_NAME_HERE
YOUR_FAVORITE_FOOD_HERE
YOUR_FAVORITE_TV_SHOW_OR_MOVIE_HERE
Make sure the third line is left blank.
Commit directly to main
- Find the Source Control icon on the left sidebar (it usually looks like a branching icon).
- You should see your new file listed under Changes.
- Next to Changes, click the + to stage the change (if staging is shown).
- In the message box, type a commit message like:
Add conflict practice file - Click Commit & Push (or Commit changes).
-
You’ve now committed directly to main! YOU NORMALLY WOULDN’T COMMIT TO MAIN.
Part D — Collaborators: “The One Change PR” (All non-owners)
Both collaborators will:
- Open the web editor
- Create a branch
- Add their info to the same file (to create future conflict conditions)
- Commit & push
- Open a Pull Request into
main
Open the repository and launch the web editor
- Go to the Repo Owner’s repository page in your browser.
- Press the period key:
.to open the web editor.
Create your own branch
- In the web editor, look at the bottom-left corner for the current branch name (it will usually say main).
- Click main.
- Choose Create new branch…
- Name it using your username in this format:
username-edits
Example:BestTeeChur-edits
- Confirm/create the branch.
You should now see your branch name in the bottom-left instead of main.
Edit the file (do not delete or replace — only add to it)
- In the file list, click
lets_make_a_conflict.md. - Add your info starting on line 5 (below the Repo Owner’s entry). Do not remove what’s already there.
- Format it like this:
- Line 5: your name
- Line 6: your favorite food
- Line 7: blank line
- Line 8: your favorite TV show or movie
So the file should look like two “blocks” of info, one after the other, with a blank line separating them.
Commit & push your changes
- Click the Source Control icon on the left sidebar.
- Under Changes, click the + to stage all changes.
- In the message box, type a commit message like:
Add my info to conflict file - Click Commit & Push.
Open a Pull Request (PR) to main
- Go back to the repository page in your browser tab (the normal GitHub page, not the editor).
- Click the bottom left button that says “GitHub”. It will open a menu from up top and you can click “Go to Repository. You can also click the back button from the web editor until you arrive. You can also open a whole new tab and manually go to your repository.
- Refresh the page (press F5 or use the browser refresh button).
- Click the Pull requests tab.
- Click the green New pull request button.
- Set the branches:
- Base:
main - Compare: your branch (example:
BestTeeChur-edits)
- Base:
- Add a title like:
Add BestTeeChur's info - In the description, write:
- What you changed (added your info)
- Why (workshop collaboration practice)
- Assign the PR to the Repo Owner:
- On the right sidebar, find Assignees
- Click Assignees
- Select the Repo Owner
- Click Create pull request.
Part E — Repo Owner: Merge ONLY ONE PR
This is after both Pull Requests have been made
- Go to the Pull requests tab in your repo.
- Open one of the submitted PRs.
- Scroll down and click the green Merge pull request button.
- Confirm the merge.
Important: Do not merge the second PR yet. That PR will now produce a merge conflict.
Part F — The merge conflict: Resolve the second PR (Repo Owner + group discussion)
What is a merge conflict (plain language)?
A merge conflict happens when GitHub sees changes that don’t “fit together” automatically—usually because two branches changed the same lines in different ways. GitHub pauses the merge so a human can decide what the final file should look like.
Open the remaining PR that was NOT merged
- In the repo, go to the Pull requests tab.
- Click the PR that is still open (the one from the third group member).
- You should see that it can’t be merged automatically.
- The merge button will be disabled/gray.
- Click Resolve conflicts (or follow the prompt GitHub provides).
Edit the conflict markers until the file looks correct
GitHub will show a conflict editor with special markers like:
<<<<<<<=======>>>>>>>
Your job: remove the markers and make the file look how you want the final version to look.
Goal for this exercise: the final file should include all group members’:
- name
- favorite food
- (blank line)
- favorite TV show/movie
…and each person’s “block” should be on separate lines, readable, and not overwriting anyone else.
Mark resolved and complete the merge
- When the file looks correct, click Mark as resolved (if shown).
- Click Commit merge (or the button GitHub shows to finalize).
- After that commit, click Merge pull request (GitHub will now allow it).
- Confirm the merge.
Best practices (helpful tips, not required)
- Use branches for all changes (even small ones) in real teamwork. Committing to
maindirectly is usually avoided outside of controlled exercises. - Write descriptive commit messages (e.g., “Add workshop participant info”).
- Keep PRs small and focused (“one change PR” is great practice).
- Communicate before editing the same lines to reduce conflicts (or intentionally coordinate when conflicts are expected).
- Use the web editor for quick edits:
- Press
.on a repo page to open it quickly in the browser editor.
- Press