Skip to content

Fast-Forward Merge

Medium — good to knowGit & Version Control

ELI5 - The Vibe Check

A fast-forward merge is git taking the lazy shortcut when it can. If your branch is simply a straight line extension of main with nothing new on main's side, merging it doesn't need an actual merge commit at all, git just slides the main pointer forward to your latest commit. It's clean and leaves a perfectly straight history, but the moment two branches have actually diverged, git can't take the shortcut and has to create a real merge commit instead.

Real Talk

A fast-forward merge occurs when the target branch's tip is a direct ancestor of the branch being merged, allowing git to move the target branch's pointer forward to the incoming branch's tip without creating a new merge commit. Teams enforce merge policy explicitly with flags like git merge --ff-only, which rejects anything that isn't a fast-forward and forces a rebase first, or git merge --no-ff, which always creates a merge commit even when a fast-forward is possible, to preserve a record that a feature branch existed.

Show Me The Code

$ git merge --ff-only feature-branch
# fails if main has diverged, forcing a rebase first
$ git merge --no-ff feature-branch
# always creates a merge commit, even if ff was possible

When You'll Hear This

"Our main branch policy is ff-only, rebase before you merge." / "We use no-ff so every feature still shows up as its own commit in the log."

Made with passive-aggressive love by manoga.digital. Powered by Claude.