git pull refuses to run because the local and remote branch both moved
Your error
hint: You have divergent branches and need to specify how to reconcile them.2 more lines it can showFix it fast
Most common cause, 1 of 3You and someone else both committed, and Git has no default to combine them
Pick a method for this pull. --no-rebase makes a merge commit; --rebase replays your commits on top of the remote ones and keeps history linear.
git pull --no-rebase # merge
# or
git pull --rebase # rebase
# remember the choice
git config set --global pull.rebase falseShort answer
git pull prints 'fatal: Need to specify how to reconcile divergent branches' when your branch and its remote each have commits the other lacks, and no pull.rebase or pull.ff setting says how to combine them. Run git status to see both counts, then pull with --no-rebase or --rebase, or reset to the remote after a force-push. Applies to Git 2.56.
Which cause do you have?
Fetch without merging, then let git status count the commits on each side. Read the fetch output too: a line that starts with + means the remote branch was force-updated (cause 3).
git fetch
git status
git log --oneline --left-right HEAD...@{u}Then find the line you see in this list and open its fix:
- 1You and someone else both committed, and Git has no default to combine them
git status says your branch and 'origin/main' have diverged, and git log lists your own commits marked < next to new remote ones marked > - 2pull.ff is set to only, so any diverged branch aborts
The last line is 'Not possible to fast-forward, aborting.' and git config get pull.ff prints only - 3The remote branch was rewritten by a force-push
git fetch printed a line starting with + and a three-dot range, and the remote side of git log holds commits whose messages match ones you already have
What does the error look like?
hint: You have divergent branches and need to specify how to reconcile them.fatal: Need to specify how to reconcile divergent branches.fatal: Not possible to fast-forward, aborting.
Cause 1 of 3
You and someone else both committed, and Git has no default to combine them
You seegit status says your branch and 'origin/main' have diverged, and git log lists your own commits marked < next to new remote ones marked >
Check
The divergent branches error comes from Git refusing to guess: the pull found local commits and remote commits, and neither pull.rebase nor pull.ff is set. Git's source only stops here when no reconcile method was given and a fast-forward is impossible. Nothing is lost at this point; the pull simply did nothing.
git config get pull.rebase
git config get pull.ffFix
Pick a method for this pull. --no-rebase makes a merge commit; --rebase replays your commits on top of the remote ones and keeps history linear. To stop the question for good, save your choice in the config, per repository or with --global.
git pull --no-rebase # merge
# or
git pull --rebase # rebase
# remember the choice
git config set --global pull.rebase falseVerify
The pull finishes, and git status reports the branch is ahead of the remote by your commits only, ready to push.
git status -sbConfirmed by git-scm.com
Cause 2 of 3
pull.ff is set to only, so any diverged branch aborts
You seeThe last line is 'Not possible to fast-forward, aborting.' and git config get pull.ff prints only
Check
With pull.ff=only, Git accepts a pull only when your branch has no commits of its own. As soon as you commit locally and someone pushes, the pull aborts. This is a safety setting many people add after seeing the first error, and it then blocks every later diverged pull.
git config get --show-origin pull.ffFix
Pass an explicit --rebase or --no-rebase for this one pull. Git's source documents that a reconcile option on the command line overrides pull.ff=only from the config, so the setting can stay in place for normal days.
git pull --rebase
# or remove the setting if you no longer want it
git config unset --global pull.ffVerify
The pull completes instead of aborting, and the log shows your commits on top of the remote ones.
git log --oneline -5Confirmed by raw.githubusercontent.com
Cause 3 of 3
The remote branch was rewritten by a force-push
You seegit fetch printed a line starting with + and a three-dot range, and the remote side of git log holds commits whose messages match ones you already have
Check
A rebase, an amend or a reset on the shared branch, followed by a force-push, replaces commits you pulled earlier. Your copy now looks diverged even if you never committed. The git-rebase manual calls this an upstream rebase and explains that everyone downstream has to repair their branch.
git log --oneline @{u}..HEADFix
If that list is empty or holds nothing you need, move your branch to the remote version. This discards local commits and uncommitted changes, so save anything first. If you do have new commits on top, pull with --rebase: when the upstream was rebased since the last fetch, Git uses that information to replay only your own changes.
git stash # only if you have uncommitted work
git reset --hard @{u}
# or, to keep your own new commits:
git pull --rebaseVerify
git status reports the branch is up to date with its remote, or ahead only by the commits you meant to keep.
git statusConfirmed by git-scm.com
How do I stop it coming back?
- Set pull.rebase once per machine with git config set --global, so every pull follows the same rule. The current git-config manual marks the older --get and plain set forms as deprecated.
- On deploy servers, run git pull --ff-only in the deploy script, so a clone with stray local commits fails loudly instead of merging.
- Protect shared branches against force-pushes in your Git host, which removes the upstream rewrite case.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.