Overview
Most Git problems only happen when two people change the same project at the same time — and that is hard to practise alone. In this project you simulate a team: two folders on your computer act as two developers, Priya and Arjun, both connected to one GitHub repository for their study group’s website.
You will see everything a real team meets in its first week: parallel feature branches, a push that GitHub rejects, a pull that refuses to guess, and a merge conflict on the same line — with the exact messages Git prints and how to respond to each.
- Using a repository-local git config so one computer can act as two people.
- Reviewing a teammate’s branch with git fetch, git log and git diff before merging it.
- Handling a rejected push, the “divergent branches” error and a content conflict.
Prerequisites
- Branches and merging, including conflicts — lessons 7 and 8.
- Remotes: push, fetch and pull — lesson 10.
- An empty GitHub repository named study-group-site (create it like in lesson 10, without a README).
Step 1: Priya Starts the Project
Make a folder for each developer. As Priya, create the repository with a README and a schedule:
mkdir priya arjuncd priyagit init study-group-sitecd study-group-site# Study Group Site
Notes and schedule for our weekend coding study group.# Schedule
- Saturday 10:00: JavaScript basics- Sunday 10:00: Git practicegit add .git commit -m "Start study group site"git remote add origin https://github.com/priya-sharma/study-group-site.gitgit push -u origin mainClick Run to see what this code prints.
Step 2: Arjun Joins
Open a second terminal for Arjun. He clones the repository into his own folder:
cd arjungit clone https://github.com/priya-sharma/study-group-site.gitcd study-group-siteClick Run to see what this code prints.
So his commits show his own name, give this one repository a local identity (no --global):
git config user.name "Arjun Mehta"git config user.email "arjun@example.com"git config user.nameClick Run to see what this code prints.
Keep one terminal in priya/study-group-site and one in arjun/study-group-site. Every command below says who runs it. Because both clones push to the same GitHub repository, they behave exactly like two teammates on two laptops.
Step 3: Parallel Work on Branches
Arjun adds a resources page on his own branch and pushes it:
git switch -c add-resources# ...create resources.md...git add resources.mdgit commit -m "Add list of learning resources"git push -u origin add-resourcesClick Run to see what this code prints.
At the same time, Priya adds a members page on her branch:
git switch -c add-members# ...create members.md...git add members.mdgit commit -m "Add members page"Click Run to see what this code prints.
Step 4: Combine and Share
Priya fetches to see Arjun’s branch, and reviews it before merging — the same thing a pull request’s Files changed tab shows:
git fetchgit log --oneline main..origin/add-resourcesgit diff --stat main origin/add-resourcesClick Run to see what this code prints.
Satisfied, she merges both branches into main and pushes:
git switch maingit merge --no-edit origin/add-resourcesgit merge --no-edit add-membersgit pushClick Run to see what this code prints.
Arjun switches to main and pulls everything in:
git switch maingit pullgit log --oneline --graphClick Run to see what this code prints.
The first merge was a fast-forward and the second created a merge commit — exactly as in lesson 8. Different files never conflict.
Step 5: The Same Line, Twice
Now both change the Saturday line of schedule.md directly on main. Arjun moves the session to 11:00 and pushes first:
git commit -am "Move Saturday session to 11:00"git pushClick Run to see what this code prints.
Priya, who has not pulled, changes the topic on the same line:
git commit -am "Change Saturday topic to functions"Click Run to see what this code prints.
Step 6: Rejected Push and Divergent Branches
git pushClick Run to see what this code prints.
GitHub refuses, because pushing would erase Arjun’s commit. The hint says to pull first:
git pullClick Run to see what this code prints.
Both sides have a commit the other lacks, so Git asks how to combine them instead of guessing. If you set pull.rebase false in lesson 2 you skip this step; otherwise choose merging for this repository and pull again:
git config pull.rebase falsegit pullClick Run to see what this code prints.
Step 7: Resolve and Push
cat schedule.mdClick Run to see what this code prints.
This time the incoming side is labelled with Arjun’s commit ID rather than a branch name, because Priya pulled main from GitHub. Both changes are valid, so she keeps both — Arjun’s new time and her new topic — and deletes the markers:
# Schedule
- Saturday 11:00: JavaScript functions- Sunday 10:00: Git practicegit add schedule.mdgit commit --no-editgit pushClick Run to see what this code prints.
Arjun pulls once more, and both copies agree:
git pullgit log --oneline --graph -4cat schedule.mdClick Run to see what this code prints.
Both conflicts came from two people editing the same line on main without pulling first. Teams avoid most of this by pulling before starting work, keeping changes on short branches, and merging through pull requests — exactly what Steps 3 and 4 did, without a single conflict.
Extend This Project
- Repeat Step 5, but this time have Priya pull with git pull --rebase. Compare the resulting graph with the merge version.
- Add a third developer folder and create a three-way conflict, then resolve it.
- Turn on branch protection for main on GitHub so direct pushes are blocked, and redo the work through pull requests.
- Invite a real friend as a collaborator under Settings → Collaborators and repeat the project with two computers.
Summary
You simulated a two-person team end to end: reviewing and merging a teammate’s branch, recovering from a rejected push, choosing how pull combines divergent work and resolving a real conflict. These are the exact situations — and messages — you will meet on your first team.