Skip to content
vast-cow's blog
Go back

Git Pull and Divergent Branches: Choosing Merge, Rebase, or Fast-Forward

Edit page

If you’ve recently run:

git pull

…and Git responded with a message like:

Pulling without specifying how to reconcile divergent branches is discouraged.

you’re not alone. Newer versions of Git are nudging users toward an explicit choice when local and remote branches have diverged.

This post explains what that warning means, why Git is asking, and how to pick the right pull strategy for your workflow.

What “Divergent Branches” Actually Means

A branch is considered divergent when:

In other words, both sides moved forward independently. When you pull, Git needs to decide how to integrate those histories.

Historically, Git defaulted to a merge-based pull in many environments. But because teams have different expectations for commit history (linear vs. explicit merges), Git now encourages you to make that preference explicit.

git pull Is Two Commands in One

It helps to remember that git pull is essentially:

  1. git fetch (download remote changes)
  2. a second step to integrate changes (merge, rebase, or fast-forward)

The warning is about step (2): the integration strategy.

The Three Strategies Git Offers

1) Merge: Preserve History as It Happened

A merge-based pull integrates the remote branch by creating a merge commit when necessary.

Pros

Cons

Set merge as default (repo or global):

git config pull.rebase false
# or
git config --global pull.rebase false

2) Rebase: Keep a Linear, Cleaner History

A rebase-based pull takes your local commits and replays them on top of the newly fetched remote branch.

Pros

Cons

Set rebase as default (repo or global):

git config pull.rebase true
# or
git config --global pull.rebase true

Optional: automatically stash uncommitted changes during rebase

git config --global rebase.autoStash true

3) Fast-Forward Only: Refuse Divergence

Fast-forward only means: “pull only if I can move my branch pointer forward without any merges or rebases.”

If the histories diverged, Git will stop and ask you to resolve it manually.

Pros

Cons

Set fast-forward only as default:

git config pull.ff only
# or
git config --global pull.ff only

One-Time Overrides (No Config Change)

If you don’t want to commit to a default yet:

git pull --no-rebase   # merge
git pull --rebase      # rebase
git pull --ff-only     # fast-forward only

This is useful when you’re in a mixed environment (e.g., rebase on feature branches, merge on main).

Which One Should You Choose?

Here are pragmatic recommendations that work well in most teams:

If you’re unsure, start with rebase for feature work and merge for mainline branches. Many teams effectively do this—either via developer convention or branch-specific tooling.

Final Thoughts

Git’s warning isn’t an error; it’s a prompt. It’s Git reminding you that commit history is part of your project’s engineering culture.

Pick the strategy that matches your team’s expectations, set it once, and move on with confidence.


Edit page
Share this post:

Comments


Previous Post
Workaround for Certbot Installation on Raspbian 11 (Bullseye) armv7l with Python 3.9
Next Post
Automating TLS Certificate Renewal with systemd and `certbot` with Strong Privilege Separation