Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git error (Cannot fast-forward to multiple branches.) when syncing during autofetch #158309

Open
jeffrson opened this issue Aug 16, 2022 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues perf
Milestone

Comments

@jeffrson
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.70.1
  • OS Version: Windows 10

Steps to Reproduce:

In a folder with Git working copy with multiple branches and valid remote:

  1. git config --local --add pull.ff only
  2. in VSCode settings "git.autofetch": true and, maybe "git.confirmSync": false, "git.autofetchPeriod": 10 (to increase chances)
  3. click git sync in status bar, a couple of times
[2022-08-16T18:25:45.833Z] > git fetch [1557ms]
[2022-08-16T18:25:45.874Z] > git status -z -uall [38ms]
[2022-08-16T18:25:45.907Z] > git symbolic-ref --short HEAD [31ms]
[2022-08-16T18:25:45.943Z] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/develop refs/remotes/develop [33ms]
[2022-08-16T18:25:45.979Z] > git remote --verbose [31ms]
[2022-08-16T18:25:45.980Z] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [35ms]
[2022-08-16T18:25:46.014Z] > git config --get commit.template [31ms]
[2022-08-16T18:25:46.640Z] > git pull --tags origin develop [1606ms]
[2022-08-16T18:25:46.640Z] From ...
 * branch            develop    -> FETCH_HEAD
fatal: Cannot fast-forward to multiple branches.

Apparently, git fetch can run during sync (or the other way around). If this occurs, there might be an error, requesting to open Git log, which contains "Cannot fast-forward to multiple branches".

@lszomoru lszomoru added bug Issue identified by VS Code Team member as probable bug git GIT issues labels Aug 16, 2022
@legioz
Copy link

legioz commented Sep 26, 2022

I have the same problem on Linux using version 1.71.2
74b1f97
x64

@lszomoru lszomoru added this to the October 2022 milestone Sep 29, 2022
@lszomoru lszomoru modified the milestones: October 2022, Backlog Oct 24, 2022
@lszomoru lszomoru added the perf label Dec 12, 2022
@movy
Copy link

movy commented Dec 17, 2022

Just encountered this in two separate repos one after another, very cryptic error, thanks for this issue.

@lszomoru lszomoru modified the milestones: Backlog, On Deck Jan 10, 2023
@starball5
Copy link

Possibly related Stack Overflow question: What is causing "Cannot fast-forward to multiple branches" during git pull?

@voneiden
Copy link

Possibly related Stack Overflow question: What is causing "Cannot fast-forward to multiple branches" during git pull?

Yes, very much related root cause.

@Namstel
Copy link

Namstel commented Jul 13, 2023

I'm also getting this when I type git pull in the terminal within VSCode. But when I then type cd .. and cd <repo> and try git pull again, it works as expected.

@Neal
Copy link

Neal commented Jul 13, 2023 via email

@joulev
Copy link

joulev commented Sep 26, 2023

I also encountered this error, but it's really hard to reproduce since it seems to just appear randomly. Just now I also saw this error, but without changing anything, after a few seconds it worked again.

@xmedeko
Copy link
Contributor

xmedeko commented Nov 14, 2023

VS Code should use git fetch --no-write-fetch-head to do autofetch.

@starball5
Copy link

@xmedeko what do you mean "shall"? Did you make a PR? Or did you mean to say "should"?

@xmedeko
Copy link
Contributor

xmedeko commented Nov 14, 2023

@starball5 I meant to say "should". I've fixed the comment. (Apologies, not a native English speaker.)

@eldarj
Copy link

eldarj commented Dec 19, 2023

I stumbled upon this even though I am not using vscode, just plain git in a terminal. Any ideas? @starball5

@starball5
Copy link

I stumbled upon this even though I am not using vscode, just plain git in a terminal. Any ideas? @starball5

I told you on SO already. If your problem has nothing to do with VS Code, you're in the wrong place asking about it here.

@juwitt
Copy link

juwitt commented Dec 22, 2023

Probably trivial, but ftr: I just encountered the same error when I had not yet pushed a commit on device A with my GitHub login and tried to pull on device B with the same login. Pushing on device A solved the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues perf
Projects
None yet
Development

No branches or pull requests