I've read a lot of other questions about the subject error message ("Not possible to fast-forward") but none of them seem to apply to my situation. I create a branch (git checkout -b issue-215
), make a change, and commit locally. I push the change, then make new changes and another local commit:
* 4b797d2a - (HEAD -> issue-215)
* 180a7ab5 - (origin/issue-215)
* 863ef01a - (origin/master, origin/HEAD, master)
ETA: as requested in a comment, the output of git branch --all -v
:
* issue-215 4b797d2a [ahead 1]
... other branches ...
master 863ef01a
remotes/origin/issue-215 180a7ab5
...other remotes....
remotes/origin/HEAD -> origin/master
remotes/origin/master 863ef01a
There are no new remote changes, but VSCode wants to pull before it pushes. That's where I get this error. So, to troubleshoot, I run git pull origin issue-215
manually, and get the following output:
$ git pull origin issue-215
From ssh://my.repo/project
* branch issue-215 -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
Keep in mind, there are no new changes on the server, and the history from my current local commit back to the branch on the remote, back to master
and origin/master
, is a straight line. I am not trying to merge or rebase, my local code is already a direct child of the branch I'm supposed to be pulling.
This only started happening about a month ago. Previously, clicking the "sync" button in VSCode would work, but since then it always fails with this error message. Could I have made some kind of gitconfig change that causes this behavior? There's not much in my global gitconfig file, and it happens with at least 2 projects so I don't think it's something I did to the repository.
CodePudding user response:
This is a known issue with Git version 2.33.1. It should be fixed in 2.33.2. Other generally-useful advice follows:
The "not possible to fast-forward" message means that you configured your git pull
to use git merge --ff-only
, perhaps using git config pull.ff only
. So git pull
is dutifully running:
git fetch origin issue-215
git merge --ff-only FETCH_HEAD
and the second command gives you the error and stops. (Edit: if you do this yourself manually and it works, you've run into the bug in footnote 1.)
Keep in mind, there are no new changes on the server, and the history from my current local commit back to the branch on the remote, back to master and origin/master, is a straight line.
Clearly (from the error), it isn't.1 After the fetch, run:
git log --all --graph --decorate --oneline FETCH_HEAD
to see where it's not; why it's not is a different question. I suspect that the answer is something along the lines of:
origin
is GitHub;- someone else is using the REBASE AND MERGE or SQUASH AND MERGE buttons;
- and thus the commit(s) you obtain with
fetch
are logically equivalent to the commit(s) you pushed earlier, but have different hash IDs.
A regular merge or a rebase would then work, but ff-only
won't. (This is not the only possible explanation: e.g., other hosting sites have the same kind of effect, but sometimes with different button labels.)
This only started happening about a month ago. Previously, clicking the "sync" button in VSCode would work, but since then it always fails with this error message. Could I have made some kind of gitconfig change that causes this behavior?
It could be something you changed, such as setting pull.ff
to only
. It could be something someone else changed, such as switching from MERGE on GitHub to REBASE AND MERGE.
1I should add that there's a bug that was just fixed on the Git mailing list where pull.ff only
rejected a no-op case that it should not have. I don't think this was in any released version of Git, just some of the experimental ones, but if it was in a release, that could potentially explain things.