Keeping Up With Main
Master keeps moving while you work. Catch up two real ways — merge and rebase — and compare the resulting graphs directly.
While you were setting up feature/dessert-menu, real work continued on master too — two more genuine commits landed there. Your feature branch is now behind, and there are two real, valid ways to catch up: merge master in, or rebase your work on top of it.\n\nThis lesson performs both, for real, on the exact same starting point — once with merge in your existing clone, once with rebase in a fresh one — so the real difference in the resulting history is something you see side by side, not just read about.
Discovering Master Has Moved
git switch feature/dessert-menu
git fetch origin
git log --oneline master..origin/master
Two real commits, genuinely landed on master while you were working elsewhere.
Catching Up With Merge
git merge origin/master --no-edit
git log --oneline --graph -8
A real merge commit, with two parents — both histories fully preserved, exactly as they happened.
Catching Up With Rebase, in a Fresh Clone
git clone ~/recipes-origin.git ~/team-recipes-2
cd ~/team-recipes-2 && git switch --track origin/feature/dessert-menu
git fetch origin
git rebase origin/master
git log --oneline --graph -8
Every real feature commit is replayed on top of the new master — genuinely new hashes, but a completely linear result, as if the feature had been started fresh from today's master.
The Real Trade-off
Merge preserves exactly what happened, including the moment of integration — valuable for traceability, but the graph gets busier. Rebase produces a clean, linear story — easier to read later, but it genuinely rewrites commit hashes, which is only safe on a branch nobody else has already pulled.
git rebase origin/<branch>
Replays the current branch's own commits, one at a time, on top of the target branch's current tip — producing a linear history with genuinely NEW commit hashes for every replayed commit. Confirmed directly in this lab: the same three feature commits got entirely different hashes after rebasing (2337c0f vs the original 9d5405c, for example).
Merge vs rebase, the real trade-off
Merge creates one real commit combining two histories, preserving exactly what happened, including a busier graph. Rebase produces a clean, linear graph by replaying commits with new hashes — readable, but only safe before anyone else has based work on the original commits.
🔍 Discover Master Has Moved
Switch back to your feature branch, fetch, and see exactly what landed on master while you were away.
cd ~/team-recipes && git switch feature/dessert-menucd ~/team-recipes && git fetch origincd ~/team-recipes && git log --oneline master..origin/masterstudent@lab:~$ cd ~/team-recipes && git switch feature/dessert-menu Switched to branch 'feature/dessert-menu' Your branch is up to date with 'origin/feature/dessert-menu'. student@lab:~$ cd ~/team-recipes && git fetch origin remote: Enumerating objects: 7, done. remote: Counting objects: 100% (7/7), done. remote: Compressing objects: 100% (6/6), done. remote: Total 6 (delta 2), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (6/6), 606 bytes | 16.00 KiB/s, done. From ../recipes-origin d891fe9..c09803f master -> origin/master student@lab:~$ cd ~/team-recipes && git log --oneline master..origin/master c09803f (origin/master, origin/HEAD) Add trail mix recipe 4ea9305 Add green smoothie recipe
🔗 Catch Up With Merge
Merge master's new commits into your feature branch, and see the real resulting graph.
cd ~/team-recipes && git merge origin/master --no-editcd ~/team-recipes && git log --oneline --graph -8student@lab:~$ cd ~/team-recipes && git merge origin/master --no-edit Merge made by the 'ort' strategy. hot-chocolate.md | 3 +++ smoothie.md | 3 +++ trail-mix.md | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 hot-chocolate.md create mode 100644 smoothie.md create mode 100644 trail-mix.md student@lab:~$ cd ~/team-recipes && git log --oneline --graph -8 * 7864e6f (HEAD -> feature/dessert-menu) Merge remote-tracking branch 'origin/master' into feature/dessert-menu |\ | * c09803f (origin/master, origin/HEAD) Add trail mix recipe | * 4ea9305 Add green smoothie recipe | * d891fe9 (origin/experiment/new-idea, master, experiment/new-idea) Add hot chocolate recipe * | f7cdea9 (origin/feature/dessert-menu) Add creme brulee recipe * | 390d424 Add panna cotta recipe * | 5a42f5c Add tiramisu recipe |/ * 5062570 Merge remote-tracking branch 'origin/master' |\
🌀 Catch Up the Same Ground With Rebase, in a Fresh Clone
Start over from the same real starting point in a fresh clone, and rebase instead of merging.
cd ~ && git clone ~/recipes-origin.git ~/team-recipes-2cd ~/team-recipes-2 && git switch --track origin/feature/dessert-menucd ~/team-recipes-2 && git fetch origincd ~/team-recipes-2 && git rebase origin/masterstudent@lab:~$ cd ~ && git clone ~/recipes-origin.git ~/team-recipes-2 Cloning into '/home/student/team-recipes-2'... done. student@lab:~$ cd ~/team-recipes-2 && git switch --track origin/feature/dessert-menu branch 'feature/dessert-menu' set up to track 'origin/feature/dessert-menu'. Switched to a new branch 'feature/dessert-menu' student@lab:~$ cd ~/team-recipes-2 && git fetch origin student@lab:~$ cd ~/team-recipes-2 && git rebase origin/master Successfully rebased and updated refs/heads/feature/dessert-menu.
📊 Compare the Two Real Graphs
See the linear result rebase produced, and compare it directly to the merge graph from a moment ago.
cd ~/team-recipes-2 && git log --oneline --graph -8student@lab:~$ cd ~/team-recipes-2 && git log --oneline --graph -8 * 2337c0f (HEAD -> feature/dessert-menu) Add creme brulee recipe * f7c6316 Add panna cotta recipe * 5d3530a Add tiramisu recipe * c09803f (origin/master, origin/HEAD, master) Add trail mix recipe * 4ea9305 Add green smoothie recipe * d891fe9 (origin/experiment/new-idea) Add hot chocolate recipe * 5062570 Merge remote-tracking branch 'origin/master' |\ | * 8634076 Add banana bread recipe
Lab 2.1.4 complete — Block 2.1 complete. The exact same catch-up, performed two real ways, compared directly:\n\n\n Master's drift discovered : ✅ two real commits\n Merge approach performed : ✅ real merge commit\n Rebase approach performed : ✅ fresh clone, linear\n Graphs compared directly : ✅ new hashes confirmed\n
Enable JavaScript to run the live terminal and track your progress.