Flutter can't switch channel to beta

2.4k Views Asked by At

I'm trying to switch the channel of Flutter to use Flutter web. But every time I'm getting this error. Neither its switching to Flutter master nor Flutter beta.

P:\FlutterProjects>flutter channel master
Switching to flutter channel 'master'...
git: From https://github.com/flutter/flutter
git:    1ad9baa8b..8af6b2f03  stable         -> origin/stable
git: error: cannot lock ref 'refs/remotes/origin/beta': unable to resolve reference 'refs/remotes/origin/beta': reference broken
git:  ! [new branch]          beta           -> origin/beta  (unable to update local ref)
git:    1ad9baa8b..8af6b2f03  flutter-1.17-candidate.3 -> origin/flutter-1.17-candidate.3
git:    df98ad6b2..0bffc8a39  master         -> origin/master
git:  * [new tag]             1.17.5         -> 1.17.5
git: error: cannot lock ref 'refs/tags/1.20.0-0.0.pre': unable to resolve reference 'refs/tags/1.20.0-0.0.pre': reference broken
git:  ! [new tag]             1.20.0-0.0.pre -> 1.20.0-0.0.pre  (unable to update local ref)
Switching channels failed with error code 1
1

There are 1 best solutions below

2
ByteMe On BEST ANSWER

In your command line navigate to the directory where flutter is installed and run the following commands

$ rm .git/refs/remotes/origin/beta
$ git fetch

If the above does not work, try the following

$ git gc --prune=now
$ git remote prune origin

The commands above will remove the broken reference and the commands below will ensure flutter is fully upgraded on the current channel before changing the channel.

$ flutter upgrade
$ flutter channel master
$ flutter upgrade