Fixing `fatal: Not possible to fast-forward, aborting.` when upgrading Flutter
Because of this new package I needed, I had to upgrade my Flutter. So I ran
flutter upgrade as usual. This time instead of upgrading without a hitch, it told me:
% flutter upgrade Upgrading Flutter from ~/flutter... From https://github.com/flutter/flutter ... fatal: Not possible to fast-forward, aborting.
So I went to the folder and ran
git status and sure enough something had happened:
flutter % git status On branch beta Your branch and 'origin/beta' have diverged, and have 2 and 467 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean
Here's the view in SourceTree:
I am not sure why it diverged though. I ran
flutter channel beta according to the docs, but that failed too:
% flutter channel beta Switching to flutter channel 'beta'... git: Already on 'beta' git: Your branch and 'origin/beta' have diverged, git: and have 2 and 467 different commits each, respectively.
To manually reset the repo back to
origin/beta I ran:
% git reset --hard origin/beta HEAD is now at 2738a1148b 1.18.0-11.1.pre beta cherrypicks (#57058)
flutter upgrade worked. Still not sure how it ever diverged in the first place though.