Skip to content
jsworkbench.
Learning path
Advanced18 min

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.

Falling behind the shared starter
SituationCommandWhere the other text comes from
A classmate's PR already mergedgit fetch originCommits on the shared starter's main
Your feature branch is behindgit pull origin mainThat teacher-approved history
After you choosegit add and git commitThe 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.

  1. 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.

  2. 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.

  3. 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.

Follow the steps. Each command step can be placed in the terminal. Edit files in the editor, then stage them.
Supported command reference
  • init
  • add <path> | add .
  • commit -m "message" | commit --amend -m "message"
  • status
  • diff | diff --staged
  • log | log --oneline | log --graph | log --oneline --graph
  • show [ref]
  • branch | branch <name> | branch -d <name>
  • checkout <ref> | checkout -b <name> | switch <name> | switch -c <name>
  • merge <branch>
  • rebase <branch> | rebase -i <branch> | rebase --edit-todo <pick|drop|reword> <hash> [message] | rebase --continue | rebase --abort
  • cherry-pick <ref>
  • reset --soft <ref> | reset --mixed <ref> | reset --hard <ref>
  • revert <ref>
  • stash | stash list | stash pop | stash apply
  • restore <path> | restore --staged <path>
  • remote | remote add <name> <repo-slug>
  • clone <repo-slug> | git clone <repo-slug> | git fork <repo-slug>
  • fetch [remote] | pull [remote] [branch] | push [remote] [branch] | push --force [remote] [branch]
  • blame <path>
  • reflog
  • tag | tag <name> [ref] | tag -d <name>
  • bisect start | bisect good [ref] | bisect bad [ref] | bisect reset
  • config <key> <value> | config --list
  • write <path> <text> (workbench: edit the working tree)
  • issue new "title" | pr new <source> <target> "title" | review "comment" | review --request-changes "comment"

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.

01Where does the other side's text come from?
02How do you finish the conflict?

Ready to call this one understood?

Mark this lesson complete to earn 200 XP. You can always revisit it.

Sign in to save progress
Next lesson