Error when trying to run `flutter upgrade`

Oto-obong Eshiett

I am trying to both upgrade my Flutter SDK and also change my Flutter channel to master, but I encounter the following error:

git: error: Your local changes to the following files would be overwritten by checkout:
git:    examples/catalog/android/build.gradle
git:    examples/catalog/android/gradle/wrapper/gradle-wrapper.properties
git:    packages/flutter_tools/gradle/flutter.gradle
git: Please commit your changes or stash them before you switch branches.
git: Aborting
Switching channels failed with error code 1.

Why does this happen and how do fix this?

creativecreatorormaybenot

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Flutter Pub Get Error when trying to run some old project

error while trying to run update and upgrade

Weird error when trying to upgrade to Fedora 24

When I run flutter upgrade on my Mac Pc I get this error below

Error when trying to run carthage

Flutter compilation error when trying to run android emulator with json_serializable package

Error run current project after flutter upgrade v3.13

Confusing error when trying to run Python script

Unexpected symbol error when trying to run a function

URI Error with Ruby when trying to run an application

KerasClassifier error when trying to run a LST Model

Parser error when trying to run a smart contract

Error when trying to run code based on PysimpleGUIqt

Syntax error when trying to run an IF EXISTS query

Compile error when trying to run make

Error when trying to run Scala Play examples

Frozen Error when trying to run rails application

Error when trying to run with GLPK on spyder

Parse error when trying to run haskell function?

Error when trying to run windows steam

Compiler error when trying to run the below program

Error when trying to run multiple mysqli queries

Error when trying to run an executable on a Linux system

Error when trying to run a max function in ocaml

Error when trying to install/remove programs after upgrade to Ubuntu 13.10

Error when trying to output "Fizz" while trying to run FizzBuzz

Flutter get error when run on the real device

When " flutter upgrade", I get "Permission denied" error

Error trying to run a Flutter WEB app, using Firebase Remote Config