Error when trying to run `flutter upgrade`

These commands executed from the Flutter install directory should get you back to a working state

git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor

Now flutter upgrade, flutter channel ..., ... should work fine again.

https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted


This occurs because the files have been changed locally. This means that the version you have on your machine is different from the one on GitHub.

The easiest way to fix this is using --force:

flutter upgrade --force

This will override any of the mismatched files. Make sure that you have no progress that would be lost by this (e.g. when you are working on a PR for flutter).


Another way of resolving this is to delete the files from your device and then execute flutter upgrade. This will resolve the Git error because it will just fetch the files from the internet again.

To do this head to your Flutter directory and remove the files. E.g. if your Flutter SDK directory was F:/data/flutter, you would need to remove the following files:

  • F:/data/flutter/examples/catalog/android/build.gradle
  • F:/data/flutter/examples/catalog/android/gradle/wrapper/gradle-wrapper.properties
  • F:/data/flutter/packages/flutter_tools/gradle/flutter.gradle

Tags:

Git

Flutter