Over the last few weeks, any time I get a merge conflict I get a fatal error.
Steps to reproduce:
- checkout branch name
- git pull origin master
At this point, my VScode would show the conflict(s) in the file and give me the opportunity of which to pick. This has happened for years..
But now, I get this error instead
* branch master -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
VScode won’t show me the conflict, there appears to be no way to resolve it except for deleting entire branch, creating a new branch from master, then rebuilding all my changes.
2
Answers
steps to fix:
% vi ~/.gitconfig
in vi, type E
in edit screen, Comment out 2 lines
#[pull]
#ff only
Save, everything works
The message:
means that you’ve told Git to use
--ff-only
for the merge that occurs as the second step ofgit pull
1 and that this merge cannot be done as a fast-forward.There was a bug in Git 2.33 where
--ff-only
misbehaved in certain cases:If you have this version of Git, you should upgrade to 2.34 or later. Your comment implies that you’ve hit this particular bug.
(Your comment about Bitbucket almost certainly involves something else entirely, and is a Bitbucket issue, not a Git one.)
1Remember that
git pull
is a convenience short-cut that means:git fetch
;The default second command is
git merge
but you can choosegit rebase
instead. The--ff-only
option is an option togit merge
and means nothing togit rebase
, sogit pull
won’t supply--ff-only
to the second command if you choosegit rebase
(but it is supposed to stop the rebase for that case). Whethergit merge
supplies--ff-only
to the second command if you choosegit merge
depends on how you configuregit pull
to operate.