Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

How to Fix "you have divergent branches and need to specify how to reconcile them"

You tried to pull the latest changes, and Git presented you with a message that looks like this:

$ git pull
You have divergent branches and need to specify how to reconcile them.
You can do so by running one of the following commands:

  git pull --rebase
  git pull --no-rebase
  git pull --ff-only

You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

This message isn't strictly an error. It's Git telling you that it needs a decision from you. It's a safeguard to ensure you don't accidentally merge changes in a way you didn't intend.

What Does This Error Mean?

This situation is identical to the "fatal: not possible to fast-forward" error. It means that both your local branch and the remote branch you're pulling from have new commits that the other doesn't have.

The histories of the two branches have diverged, so Git is simply asking: "How do you want to combine these two different lines of work?"

How to Fix It

The message itself gives you the solution — you have to tell Git which strategy to use to combine the divergent histories. You can do this for a single pull, or you can set a permanent configuration so you don't have to see this message again.

The One-Time Fix

To solve this for the current pull, you can use one of the commands Git suggests:

  • git pull --rebase: This will perform a rebase. It will take your local commits, put them aside, pull the remote changes, and then re-apply your commits on top of the new remote changes. This creates a clean, linear history.
  • git pull --no-rebase: This will perform a merge. It will fetch the remote changes and then create a new "merge commit" to tie the two histories together. This is the traditional default behavior.

The Permanent Fix: Configuring Your Pull Strategy

If you find yourself using the same option every time, you can tell Git to make it the default. This is a great way to ensure consistency and avoid seeing this message in the future.

Run one of the following commands:

  • To always use rebase:

    git config --global pull.rebase true

    This is a popular choice for teams that prefer a clean, linear commit history.

  • To always use merge (and create a merge commit):

    git config --global pull.rebase false

    This will create an explicit merge commit every time there are divergent changes, which some teams prefer for its clear record of integration.

  • To only allow fast-forward merges:

    git config --global pull.ff only

    This is the strictest option. It tells Git to only update your local branch if it can be "fast-forwarded" without creating a merge commit. If there are divergent changes, the pull will fail, and you'll have to fetch and merge/rebase manually.

Which Strategy Should You Choose?

The choice between merging and rebasing is mostly a matter of workflow preference.

  • Rebasing leads to a cleaner, easier-to-read history. It looks as if all the work was done in a straight line.
  • Merging preserves the exact history of what happened, including when branches were created and merged.

Many developers prefer rebasing for their local feature branches before merging them into a main branch to keep the main branch's history clean.

The important thing is to be consistent within your team. Once you set a global configuration, you'll have a smoother, more predictable workflow.

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.