Fast-Forward Merge
Part of the Version Control section of Coddy's Terminal journey — lesson 35 of 58.
A fast-forward merge happens when the target branch has no new commits of its own. Git can simply move the branch pointer forward to catch up with the work on the side branch.
Picture main sitting at commit A. You branch off, make commits B and C on feature, and never touch main. When you switch back and merge:
git switch main
git merge featureGit notices the path from A to C is a straight line, so it just moves the main pointer up to C. No new merge commit is created. The history stays linear.
Fast-forward merges are the cleanest result you can get. They happen automatically when nothing else has touched the target branch in the meantime.
Challenge
EasyThe folder contains app.txt. Set up the repo, make a first commit on main, then create a branch feature with a single commit that adds a line extra to app.txt.
Switch back to main and merge feature. Print the contents of app.txt on main.
Cheat sheet
Fast-forward merge occurs when the target branch has no new commits of its own — Git simply moves the branch pointer forward. No merge commit is created and history stays linear.
git switch main
git merge featureTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore