Flutter upgrade error: Your local changes to the following files would be overwritten
Upgrading the Flutter SDK and packages
My-Mac:~ admin$ flutter upgrade
Upgrading Flutter from /Users/admin/Desktop/SDK/flutter...
error: Your local changes to the following files would be overwritten by merge:
packages/flutter/lib/src/services/message_codecs.dart
Please commit your changes or stash them before you merge.
Aborting
Updating 2eeeXXXe9..7XXXbf4aX
I have gone on the flutter SDK and check status
and got below things
My-Mac:flutter admin$ git status
On branch master
Your branch is behind 'origin/master' by 565 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: dev/automated_tests/pubspec.yaml
modified: dev/benchmarks/complex_layout/pubspec.yaml
modified: dev/benchmarks/macrobenchmarks/pubspec.yaml
modified: dev/benchmarks/microbenchmarks/pubspec.yaml
modified: dev/bots/pubspec.yaml
modified: dev/devicelab/pubspec.yaml
modified: dev/integration_tests/android_semantics_testing/pubspec.yaml
modified: dev/integration_tests/android_views/pubspec.yaml
modified: dev/integration_tests/channels/pubspec.yaml
modified: dev/integration_tests/external_ui/pubspec.yaml
modified: dev/integration_tests/flavors/pubspec.yaml
modified: dev/integration_tests/platform_interaction/pubspec.yaml
modified: dev/integration_tests/ui/pubspec.yaml
modified: dev/manual_tests/pubspec.yaml
modified: dev/snippets/pubspec.yaml
modified: dev/tools/pubspec.yaml
modified: dev/tools/vitool/pubspec.yaml
modified: examples/catalog/pubspec.yaml
modified: examples/flutter_gallery/pubspec.yaml
modified: examples/hello_world/pubspec.yaml
modified: examples/layers/pubspec.yaml
modified: examples/platform_channel/pubspec.yaml
modified: examples/platform_channel_swift/pubspec.yaml
modified: examples/stocks/pubspec.yaml
modified: packages/flutter/lib/src/services/message_codecs.dart
modified: packages/flutter/pubspec.yaml
modified: packages/flutter_driver/pubspec.yaml
modified: packages/flutter_goldens/pubspec.yaml
modified: packages/flutter_localizations/pubspec.yaml
modified: packages/flutter_test/pubspec.yaml
modified: packages/flutter_tools/pubspec.yaml
modified: packages/fuchsia_remote_debug_protocol/pubspec.yaml
Untracked files:
(use "git add <file>..." to include in what will be committed)
OLDSDK.zip
no changes added to commit (use "git add" and/or "git commit -a")
After do above task now try to upgrade again Flutter but got again error mentioned below
My-Mac:flutter admin$ flutter upgrade
Building flutter tool...
Because flutter_tools depends on sockjs_client 0.3.5 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
.
.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (1 tries left)
Command 'pub upgrade' still failed after 10 tries, giving up.
Solution 1:
Flutter uses git for SDK management. You'd need to review your repository located in $HOME/development/flutter. You can use git command to check your repostory status. For example,
$ git status
To see your local change
$ git branch
To see which branch you are using.
Following steps might help you when you find you've changed something uncommitted, but you would like to undo all changed to simply switch to latest version (master).
$ git reset --hard HEAD
To undo all your changes.
$ git checkout master
To switch to master branch
$ git pull
To pull down and sync all commit on server.