Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Git: fatal: Need to specify how to reconcile divergent branches

Git 2.34 and later refuse to guess between merge, rebase and fast-forward. Set pull.rebase or pull.ff once, and know what each strategy does to history.

~5 min readGit
#git#pull#rebase#merge
Git branch rails diverging around a strategy plate with merge and rebase paths

Introduction & Quick Summary

A git pull that used to work now stops before touching anything:

code
$ git pull hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only fatal: Need to specify how to reconcile divergent branches.

Quick answer: Git refuses to guess how to combine your local commits with the remote ones. Pick the strategy you want for this repository and record it once:

bash
git config --global pull.rebase false # merge (creates a merge commit) git config --global pull.rebase true # rebase (linear history, rewrites your commits) git config --global pull.ff only # fast-forward only (refuses, then you choose)

Or decide per pull without changing any configuration:

bash
git pull --no-rebase # merge now git pull --rebase # rebase now git pull --ff-only # fail instead of merging

The message is not an error in your repository; it is Git declining to invent a policy. This guide covers what each strategy does to history, how to choose one per project, and how to recover if you pick the wrong one.

Core Mechanics, Signatures & Reproducible Setup

Divergence means both sides moved: you have commits the remote does not, and the remote has commits you do not.

bash
git status -sb ## main...origin/main [ahead 2, behind 3]

A pull is fetch plus one of three integration steps. The setting that selects it comes from pull.rebase, pull.ff, and the --rebase/--ff flags; in Git 2.34 and later, a pull that would need a merge or rebase while none is configured stops with the fatal message instead of defaulting to merge.

A reproducible divergence in a scratch repository:

bash
git init diverge && cd diverge git commit --allow-empty -m "base" git remote add origin "$(pwd)/../remote.git" git push -u origin main # local commit git commit --allow-empty -m "local work" # remote moves too git clone ../remote.git ../other && cd ../other git commit --allow-empty -m "remote work" && git push cd ../diverge git fetch git pull # fatal: Need to specify how to reconcile divergent branches.

The three answers to that prompt, and what each one writes:

ConfigurationIntegrationHistory after pullRewrites local commits
pull.rebase falsemergemerge commit joining both linesno
pull.rebase truerebaseyour commits replayed on top of the remoteyes
pull.ff onlyfast-forward onlynothing, refuses while divergedno
unset, no flagnonepull aborts with the fatal message—

git pull alone cannot fast-forward while diverged, which is exactly why the choice cannot be inferred. A repository that never has local commits on the branch never sees this message; a shared branch where everyone commits locally sees it constantly.

Key Comparison Table

SituationBest choiceCommand
shared branch, merge commits acceptedmergegit config pull.rebase false
feature branch kept linear before reviewrebasegit config pull.rebase true
CI or deploy branch that must stay linearfast-forward onlygit config pull.ff only
one-off inspection of remote workfetch, then inspectgit fetch && git log --oneline HEAD..origin/main
local commits are already pushedmerge, never rebasegit pull --no-rebase
long-lived local branch with uncommitted editsrebase with autostashgit -c rebase.autoStash=true pull --rebase
SymptomMeaningNext step
fatal message with no outputno strategy configuredchoose one of the three settings
Not possible to fast-forward, abortingpull.ff only activegit rebase origin/main explicitly
merge commit appears in every pullpull.rebase falsekeep it, or switch to rebase
every local branch gets rewrittenpull.rebase true globallyoverride per repo with --no-rebase
conflict stops mid-pullintegration needs resolutionresolve, git add, git rebase --continue or git commit
CommandEffect
git config --show-origin pull.rebaseshows the value and which file set it
git pull --rebase=mergesrebases but keeps merge commits in your local history
git pull --autostashstashes local changes, pulls, then restores them
git merge --abortabandons a conflicted merge
git rebase --abortabandons a conflicted rebase
git reset --hard ORIG_HEADreturns to the state before the last pull

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Read the state before choosing

The strategy depends on what each side contains, so look first:

bash
git fetch git log --oneline --left-right --graph HEAD...origin/main # < abc1234 local commit # > def5678 remote commit

If the right side contains work you have already pushed from another machine, rebasing your left-side commits is usually right. If both sides are shared with teammates, merging is safer because it never rewrites commits others may have.

2. Merge: the default that never rewrites

bash
git config pull.rebase false git pull

Git performs a real merge, producing a merge commit when the histories diverged. Conflicts stop the pull with the usual markers; resolve, git add the files, and git commit to finish. This is the setting to pick on a branch where several people push, because nobody's commit ids change.

3. Rebase: linear history at the cost of rewriting

bash
git config pull.rebase true git config rebase.autoStash true git pull

Your local commits are replayed on top of the fetched ones, so the branch looks as if you had started from the newest remote commit. Two consequences matter: commit hashes change, and a branch that others already pulled will need a force push after the rebase. Conflicts are resolved once per commit, with git rebase --continue after each, or git rebase --skip to drop a commit.

bash
git pull --rebase # CONFLICT (content): Merge conflict in src/app.ts git add src/app.ts git rebase --continue # if it goes wrong: git rebase --abort

rebase.autoStash handles the very common "cannot pull with rebase: You have unstaged changes" failure by stashing and restoring around the operation.

4. Fast-forward only: refuse, then decide

pull.ff only never creates a merge commit and never rewrites: it fails when the branch diverged, which is a feature on deployment branches where an unexpected merge commit can break a linear pipeline.

bash
git config pull.ff only git pull # fatal: Not possible to fast-forward, aborting. git rebase origin/main # explicit decision, visible in the shell history

The per-invocation form git pull --ff-only is useful in scripts where the global setting is merge or rebase.

5. Multiple configs and the value that actually wins

Git layers system, global, local and worktree configuration, and the last one wins per key. When the message persists after setting a value, inspect the origin:

bash
git config --show-origin --get-all pull.rebase git config --list --show-origin | grep -E "pull\.|rebase"

An included file, a git config --system entry on a managed machine, or a repository-local pull.rebase = false left over from a script all override your global choice. Set the value where you intend it and remove the stale one:

bash
git config --local --unset pull.rebase git config --global pull.rebase true

6. Undo a strategy you did not want

Both integrations are reversible from ORIG_HEAD, which the pull sets before it changes anything:

bash
git reset --hard ORIG_HEAD # before pushing anything git reflog -n 10 # if ORIG_HEAD is gone git reset --hard HEAD@{1}

After a rebase that was already pushed, the recovery needs git push --force-with-lease; on a shared branch, coordinate first, because the rewritten commits are no longer what teammates have. The text diff tool is handy for reading a conflicted file outside the editor, and the regex tester helps when a filter in .gitattributes is rewriting line endings during the pull.

Common Compilation/Runtime Mistakes & Version Gotchas

  • Setting pull.rebase true globally on shared branches. Every pull rewrites local commits; teammates who already have them get divergence again on the next fetch.
  • Choosing pull.ff only and stopping there. The branch then never incorporates remote work until someone runs an explicit rebase or merge.
  • Ignoring the origin of the config. --show-origin is faster than guessing which of three config files set the value.
  • Rebasing pushed commits. It requires a force push and invalidates every open branch based on those commits; merge instead.
  • Resolving a rebase conflict with git commit. A rebase expects git rebase --continue so the commit message and author are preserved.
  • Version notes. Git 2.27 added the hint, and Git 2.34 turned it into a fatal error when the branches diverge and no strategy is configured — which is why the same workflow broke for many teams on an upgrade. git config --global pull.ff only and --rebase=merges are both supported in current releases; init.defaultBranch and pull.rebase remain separate settings.

Official documentation: git pull and pull.rebase in git-config.

Official references

primary documentation

The Git documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Git work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Git guides

More in Git

All Git guides

The guides filed next to this one in Git, in library order.