Resolving conflicts with a teammate
Understand the idea
When another student's PR merges into the shared starter, your branch can fall behind real history.
The idea
git fetch origin copies the shared starter (your ). git pull origin main merges that main into your feature branch. If a classmate's teacher-approved pull request already changed the same lines, you get a . You edit the file, git add it, and commit. That commit is catching up with the class repository's real history.
What changes
Fetch does not move your . The merge either moves your label, creates a merge commit, or stops with markers in the working tree. The shared starter stays as the teacher left it after merging the other PR. Your job is to bring that history into your branch before asking again.
| Situation | Command | Where the other text comes from |
|---|---|---|
| A classmate's PR already merged | git fetch origin | Commits on the shared starter's main |
| Your feature branch is behind | git pull origin main | That teacher-approved history |
| After you choose | git add and git commit | The text you left in the file |
The command
Assume the shared starter's main moved because another student's PR merged. On your feature branch, git fetch origin, then git pull origin main. If markers appear, delete them and keep the combined text you want. git add the file and commit. git log --oneline --graph shows both parents when the histories had diverged.
The mistake
Check your graph
The merge commit lists two parents, or your label fast-forwarded if you had not diverged. The file no longer contains the marker text. Your branch now includes the shared starter's teacher-approved history.
Your repository
Fetch the shared starter after a classmate's merge, catch up your branch, and resolve any conflict with that teacher-approved history.
Step 1
Fetch the shared starter
origin is the class starter. Another student’s teacher-approved PR may already be on its main. Fetch copies those real commits without moving your branch.
Step 2
Catch up your branch
Merge the shared main into your feature branch. If they edited the same lines you did, the editor shows conflict markers. Resolve them against that merged history, then git add and git commit.
Step 3
Show the join
A merge commit has two parents when your branch had diverged from the starter.
The editor edits the working tree. Start a repository and the files appear here.
Commit graph
No commits yet. git init creates the first one.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 200 XP. You can always revisit it.