LearnAI ToolsCareerPractice BuildsPlayDevelopmentContact
Git & GitHubIntermediate~1.5 hours

Team Collaboration Simulation

Play two developers on two clones of one repository: parallel feature branches, a rejected push, a pull that needs a decision, and a real merge conflict resolved cleanly.

BranchesFetch & PullMerge ConflictsRejected Pushes

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.

What You'll Practise
  • 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 arjun
cd priya
git init study-group-site
cd study-group-site
README.md
# Study Group Site
Notes and schedule for our weekend coding study group.
schedule.md
# Schedule
- Saturday 10:00: JavaScript basics
- Sunday 10:00: Git practice
git add .
git commit -m "Start study group site"
git remote add origin https://github.com/priya-sharma/study-group-site.git
git push -u origin main
Output

Click 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 arjun
git clone https://github.com/priya-sharma/study-group-site.git
cd study-group-site
Output

Click 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.name
Output

Click Run to see what this code prints.

Two Terminals, Two People

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.md
git commit -m "Add list of learning resources"
git push -u origin add-resources
Output

Click 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.md
git commit -m "Add members page"
Output

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 fetch
git log --oneline main..origin/add-resources
git diff --stat main origin/add-resources
Output

Click Run to see what this code prints.

Satisfied, she merges both branches into main and pushes:

git switch main
git merge --no-edit origin/add-resources
git merge --no-edit add-members
git push
Output

Click Run to see what this code prints.

Arjun switches to main and pulls everything in:

git switch main
git pull
git log --oneline --graph
Output

Click 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 push
Output

Click 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"
Output

Click Run to see what this code prints.

Step 6: Rejected Push and Divergent Branches

git push
Output

Click Run to see what this code prints.

GitHub refuses, because pushing would erase Arjun’s commit. The hint says to pull first:

git pull
Output (if pull.rebase is not configured)

Click 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 false
git pull
Output

Click Run to see what this code prints.

Step 7: Resolve and Push

cat schedule.md
Output

Click 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.md (resolved)
# Schedule
- Saturday 11:00: JavaScript functions
- Sunday 10:00: Git practice
git add schedule.md
git commit --no-edit
git push
Output

Click Run to see what this code prints.

Arjun pulls once more, and both copies agree:

git pull
git log --oneline --graph -4
cat schedule.md
Output

Click Run to see what this code prints.

The Lesson in This Project

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.