I'am getting an error when I run flutter upgrade command.
Upgrading Flutter from E:\flutter...
Updating f37c235c3..5391447fa
error: Your local changes to the following files would be overwritten by merge:
packages/flutter_tools/gradle/flutter.gradle
Please commit your changes or stash them before you merge.
Aborting
It's because you have made some changes in this file:
<FlutterRoot>/packages/flutter_tools/gradle/flutter.gradle
that's the root directory of flutter, where there is also the bin
folder.
Maybe you have made such modifications in order to have some gradle rules to be spreaded to all your flutter projects, I don't know, you should know ;-]
When we have flutter root path that has some modifications made by us (either because we need it or unintended) when we try to update flutter or change flutter channel we get an error.
In this cases we have two paths to choose:
Go to <FlutterRoot>
and
git checkout .
(or stash
them if you now what that means) .Discarding changes is a destructive action, so you should backup or at least know if these are wanted and useful modifications so that you can add them again after and update or a change of channel
Today there's also a section in the flutter github official repo wiki to address this scenario:
Workarounds-for-common-issues
Here you can find this solution
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor
The first command remove all untrack repo files (for example if you add a file of yours) and the third line drop your previous stash.
So this is a destructive command like git checkout .
but it also clean all files that don't belong to the standard flutter repo.
If haven't intended modification on your flutter root project forlder you could choose either git checkout .
or the above bunch of commands.
But if you had modification that you need to preserve, you can choose the following solution or stash this modification but not drop this stash, otherwise you will loose it.
git add . && git commit -m "my changes whatever"
and see if flutter update
can merge the flutter official changes with yours.If you don't remember where <FlutterRoot>
is you could type:
which flutter
where flutter
This should print <FlutterRoot>/bin/flutter
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With