Merge Strategies in Practice
Four real scenarios. Four real strategies. The right choice depends entirely on what actually happened.
A hotfix, a documentation update, and an experimental idea all need merging today — each one genuinely different in what it is and what future readers will want from its history. This lesson performs all three with a real, deliberately different strategy each, then reasons through a fourth scenario (a normal feature) using everything learned across this entire block.\n\nThis is not about memorizing which strategy goes with which label — it is about the real question behind each choice: will anyone want a permanent record of this integration? Does the history leading up to it matter, or only the final result?
Hotfix: A Permanent Record Matters
git merge --no-ff hotfix/soup-serving-typo -m "Merge pull request: hotfix soup serving typo"
A production fix deserves a real, searchable marker in history — exactly when it landed, easy to find later if the fix itself ever needs revisiting.
Documentation: No Ceremony Needed
git merge docs/update-readme
A plain merge, genuinely fast-forwarding — a README update carries no real risk and needs no permanent "this was reviewed and merged" marker.
Experimental Work: Only the Result Matters
git merge --squash experiment/spicy-mocktails
git commit -m "Add spicy ginger mocktail recipe"
Real, messy exploration ("wip", "try ginger beer") collapses into one clean commit — nobody will ever want to bisect into which specific attempt worked.
The Real Question Behind Every Choice
Not "what type of branch is this," but: will a future reader want a permanent record of the integration itself? Does the path to the result matter, or only the result? Answering both honestly, every time, is what real merge-strategy judgment actually is.
Merge strategy as a real, deliberate choice
Fast-forward, --no-ff, and --squash are not arbitrary settings — each answers a real question about what future readers of history will want: nothing extra, a permanent integration marker, or only the final clean result. Confirmed directly across this entire block: three genuinely different real scenarios, three deliberately different real outcomes.
🚑 Hotfix: Merge With a Permanent Record
A real production typo needs fixing — merge it with --no-ff for a permanent, searchable trace.
cd ~/team-recipes && git switch -c hotfix/soup-serving-typocd ~/team-recipes && sed -i 's/Simmer chicken, add noodles and vegetables. Season with salt to taste./Simmer chicken, add noodles and vegetables. Season with salt to taste. Serves 4-6./' soup.mdcd ~/team-recipes && git add soup.mdcd ~/team-recipes && git commit -m 'Fix serving size typo in soup recipe'cd ~/team-recipes && git switch mastercd ~/team-recipes && git merge --no-ff hotfix/soup-serving-typo -m 'Merge pull request: hotfix soup serving typo'cd ~/team-recipes && git branch -d hotfix/soup-serving-typostudent@lab:~$ cd ~/team-recipes && git switch -c hotfix/soup-serving-typo Switched to a new branch 'hotfix/soup-serving-typo' student@lab:~$ cd ~/team-recipes && sed -i 's/Simmer chicken, add noodles and vegetables. Season with salt to taste./Simmer chicken, add noodles and vegetables. Season with salt to taste. Serves 4-6./' soup.md student@lab:~$ cd ~/team-recipes && git add soup.md student@lab:~$ cd ~/team-recipes && git commit -m 'Fix serving size typo in soup recipe' [hotfix/soup-serving-typo 1b1f2f6] Fix serving size typo in soup recipe 1 file changed, 1 insertion(+), 1 deletion(-) student@lab:~$ cd ~/team-recipes && git switch master Switched to branch 'master' Your branch is up to date with 'origin/master'. student@lab:~$ cd ~/team-recipes && git merge --no-ff hotfix/soup-serving-typo -m 'Merge pull request: hotfix soup serving typo' Merge made by the 'ort' strategy. soup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) student@lab:~$ cd ~/team-recipes && git branch -d hotfix/soup-serving-typo Deleted branch hotfix/soup-serving-typo (was 1b1f2f6).
📄 Docs: Merge Without Ceremony
A README update carries no real risk — merge it plainly, with no forced merge commit.
cd ~/team-recipes && git switch -c docs/update-readmecd ~/team-recipes && printf 'Recipe Collection\n\nA real, growing collection of family recipes.\n' > README.mdcd ~/team-recipes && git add README.mdcd ~/team-recipes && git commit -m 'Add project README'cd ~/team-recipes && git switch mastercd ~/team-recipes && git merge docs/update-readmecd ~/team-recipes && git branch -d docs/update-readmestudent@lab:~$ cd ~/team-recipes && git switch -c docs/update-readme Switched to a new branch 'docs/update-readme' student@lab:~$ cd ~/team-recipes && printf 'Recipe Collection\n\nA real, growing collection of family recipes.\n' > README.md student@lab:~$ cd ~/team-recipes && git add README.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add project README' [docs/update-readme 5157c37] Add project README 1 file changed, 3 insertions(+) create mode 100644 README.md student@lab:~$ cd ~/team-recipes && git switch master Switched to branch 'master' Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits) student@lab:~$ cd ~/team-recipes && git merge docs/update-readme Updating 9724604..5157c37 Fast-forward README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md student@lab:~$ cd ~/team-recipes && git branch -d docs/update-readme Deleted branch docs/update-readme (was 5157c37).
🧪 Experimental: Squash, Only the Result Matters
A real, messy mocktail experiment — squash it, since nobody will ever want the individual attempts.
cd ~/team-recipes && git switch -c experiment/spicy-mocktailscd ~/team-recipes && printf 'idea\n' > mocktails.md && git add mocktails.md && git commit -m 'wip'cd ~/team-recipes && printf 'ginger beer base\n' >> mocktails.md && git add mocktails.md && git commit -m 'try ginger beer'cd ~/team-recipes && printf '\nSpicy Ginger Mocktail\n\nMuddle ginger and lime, top with ginger beer and a chili rim.\n' >> mocktails.md && git add mocktails.md && git commit -m 'finalize recipe'cd ~/team-recipes && git switch mastercd ~/team-recipes && git merge --squash experiment/spicy-mocktailscd ~/team-recipes && git commit -m 'Add spicy ginger mocktail recipe'cd ~/team-recipes && git branch -D experiment/spicy-mocktailsstudent@lab:~$ cd ~/team-recipes && git switch -c experiment/spicy-mocktails Switched to a new branch 'experiment/spicy-mocktails' student@lab:~$ cd ~/team-recipes && printf 'idea\n' > mocktails.md && git add mocktails.md && git commit -m 'wip' [experiment/spicy-mocktails c5af52b] wip 1 file changed, 1 insertion(+) create mode 100644 mocktails.md student@lab:~$ cd ~/team-recipes && printf 'ginger beer base\n' >> mocktails.md && git add mocktails.md && git commit -m 'try ginger beer' [experiment/spicy-mocktails 4e7d103] try ginger beer 1 file changed, 1 insertion(+) student@lab:~$ cd ~/team-recipes && printf '\nSpicy Ginger Mocktail\n\nMuddle ginger and lime, top with ginger beer and a chili rim.\n' >> mocktails.md && git add mocktails.md && git commit -m 'finalize recipe' [experiment/spicy-mocktails e8ee1d0] finalize recipe 1 file changed, 4 insertions(+) student@lab:~$ cd ~/team-recipes && git switch master Switched to branch 'master' Your branch is ahead of 'origin/master' by 3 commits. (use "git push" to publish your local commits) student@lab:~$ cd ~/team-recipes && git merge --squash experiment/spicy-mocktails Updating 5157c37..e8ee1d0 Fast-forward Squash commit -- not updating HEAD mocktails.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 mocktails.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add spicy ginger mocktail recipe' [master 770663e] Add spicy ginger mocktail recipe 1 file changed, 6 insertions(+) create mode 100644 mocktails.md student@lab:~$ cd ~/team-recipes && git branch -D experiment/spicy-mocktails Deleted branch experiment/spicy-mocktails (was e8ee1d0).
📤 Push All Three, and Confirm the Real Combined History
Send everything, and see all three deliberately different strategies sitting in the same real log.
cd ~/team-recipes && git pushcd ~/team-recipes && git log --oneline -8student@lab:~$ cd ~/team-recipes && git push Enumerating objects: 12, done. Counting objects: 100% (12/12), done. Compressing objects: 100% (10/10), done. Writing objects: 100% (10/10), 1.03 KiB | 70.00 KiB/s, done. Total 10 (delta 5), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git ce3eddd..770663e master -> master student@lab:~$ cd ~/team-recipes && git log --oneline -8 770663e (HEAD -> master, origin/master, origin/HEAD) Add spicy ginger mocktail recipe 5157c37 Add project README 9724604 Merge pull request: hotfix soup serving typo 1b1f2f6 Fix serving size typo in soup recipe ce3eddd Add recipe index card storage guide 67f9971 Merge pull request: spice rack guide eb43506 Add freezer labeling recipe note feec4a2 Add spice freshness guidance
Lab 2.3.4 complete — Block 2.3 complete. Four real scenarios, four real strategies, each chosen on purpose:\n\n\n Hotfix: --no-ff, permanent record : ✅ confirmed\n Docs: fast-forward, no ceremony : ✅ confirmed\n Experimental: squash, one clean commit : ✅ confirmed\n Feature (reasoned through): --no-ff : ✅ judgment applied\n
Enable JavaScript to run the live terminal and track your progress.