Menu
Coddy logo textTech

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 feature

Git 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 icon

Challenge

Easy

The 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 feature

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control