I recently started using a new machine and noticed this error hint when attempting to push to a branch after I resolved something online earlier on GitHub and forgot to pull.
So I pulled, and usually when I do this, I would get a list of the files that had changes and need to resolve them, add them, and then push.
However, something different happened today when encountering this. I got this message:
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
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.
Whenever setting up a new machine, I've never seen this before. I'm using the same .gitconfig
on two other machines where I haven't seen this message:
[user]
name = my name
email = my email
[format]
numbered = auto
[color]
branch = yes
diff = auto
pager = yes
status = auto
I've done this many times, and I suddenly have amnesia. I do not recall this hint/error from Git ever (six years). Is this new? Maybe I can look at history of Git's source? If not, what's the default?
It is indeed new (partly introduced in Git 2.27, with a fix in 2.29): you can and should now configure pull.rebase
and pull.ff
to some setting(s).
The previous default default was the equivalent of pull.rebase false
and pull.ff true
. This makes git pull
run git merge
, doing a fast-forward non-merge "fake" merge if possible, or a real merge if not possible.
Configuring pull.ff
to only
makes git pull
run the equivalent of git merge --ff-only
as its second command (provided you're not rebasing). This is my general personal preference, but I don't have Git 2.29 or later everywhere, so I still use my own run git fetch
, then poke around, then decide and maybe use my git mff
alias to do a fast-forward-only merge process.