'What is causing "Cannot fast-forward to multiple branches" during `git pull`?
We use the default workflow on GitHub, i.e., create a feature branch, push some commits to it, merge to master. Nothing fancy.
In the master branch, I only ever pull newer changes from GitHub, never push. In visual terms, the "down" direction in VSCode typically contains some commits while the "up" direction doesn't:

Now, from time to time (not always!), invoking the sync in VSCode which is git pull origin master
ends up with this error:
> git pull origin master
From https://github.com/shoptet/sofa
* branch master -> FETCH_HEAD
fatal: Cannot fast-forward to multiple branches.
What does the error mean? I don't see any multiple branches.
It's important to note that after I run the operation again, it works. So my workflow usually is:
- Click the "sync" button in VSCode (runs
git pull origin master
) - See the "Cannot fast-forward to multiple branches" error, dismiss it.
- Click the "sync" button again, see it succeed.
A bit annoying.
BTW my repo is in a clean state:
$ git status
On branch master
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working tree clean
One additional thing that can be related as I think this problem only started happening after I enabled it is ff=only
in my Git config – the full section looks like this:
[pull]
rebase = false
ff = only
I also looked in the VSCode logs and there's an additional git fetch
before – I'm not sure if this changes something or not:
[2022-05-04T06:27:11.853Z] > git fetch [2373ms]
[2022-05-04T06:27:11.853Z] From https://github.com/shoptet/sofa
* [new branch] 1997-fix-pnpm -> origin/1997-fix-pnpm
* [new branch] debug-build -> origin/debug-build
[2022-05-04T06:27:11.892Z] > git symbolic-ref --short HEAD [3ms]
[2022-05-04T06:27:11.897Z] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track) refs/heads/master refs/remotes/master [4ms]
[2022-05-04T06:27:11.901Z] > git remote --verbose [3ms]
[2022-05-04T06:27:11.905Z] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [7ms]
[2022-05-04T06:27:11.909Z] > git config --get commit.template [3ms]
[2022-05-04T06:27:12.498Z] > git pull origin master [1918ms]
[2022-05-04T06:27:12.498Z] From https://github.com/shoptet/sofa
* branch master -> FETCH_HEAD
fatal: Cannot fast-forward to multiple branches.
I'd like to understand what the error means and how to get rid of it.
I'm on Git 2.36.0 and VSCode 1.66.2.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|