Lesson06
intermediateSync with a Teammate's Push
Goal
Fetch a teammate's work, integrate it with yours, and push the result.
You committed Add forecast panel on main. While you worked, Sam pushed Fix units in header to origin. Your repository has not heard about it yet: git status still says you are simply one commit ahead.
Bring Sam's commit in, keep yours, and publish both. If you push first, origin will refuse, and that is part of the lesson.
Objectives
0/4origin/mainknows about Sam's commit. (Current objective)- Your
maincontainsFix units in header. (Not started) - Your
mainstill containsAdd forecast panel. (Not started) origin'smainis where yourmainis. (Not started)
Your task nowStep 1 of 4
origin/main knows about Sam's commit.
Need help?
Reference
A push that would lose work
$ git push
To gitdojo://simulated/origin.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'gitdojo://simulated/origin.git' hint: Updates were rejected because the remote contains work that you do not hint: have locally.
A push may only move a remote branch forward. origin/main has a commit your main does not, so accepting your push would throw Sam's commit away. Nothing changed, on either side.
Fetch, rebase, push
Step 1 of 2
$ git fetch
After git fetch, origin/main moves to Sam's commit S. Your main and its files are untouched: the two lines of work have diverged.
Step 1 of 2. git fetch. After `git fetch`, `origin/main` moves to Sam's commit S. Your `main` and its files are untouched: the two lines of work have diverged.
Preparing your workspace…
Repository Graph
Click a commit to inspect it
Working Tree
Not a Git repository yet
No unstaged changes
Your working tree matches the staging area.
Staging Area
Files prepared for the next commit
No staged changes
Use git add to prepare files for your next commit.
Repository
Committed history
No commits yet
Use git commit to record staged changes.
