flutter升级错误“Your flutter checkout has local changes that would be erased by upgrading. ”

在升级Flutter SDK时可能会报如下错误:

Your flutter checkout has local changes that would be erased by upgrading. If you want to keep these changes, it is recommended that you stash them via “git stash” or else commit the changes to a local branch. If it is okay to remove local changes, then re-run this command with --force.
exit code 1

这是因为在之前下载老版本的Flutter SDK时,其git分支可能在beta版本之下,测试版本与开发版/稳定版有版本差异,此时如果需要升级需要切换到稳定/开发版本之下。运行``命令,查看当前SDK分支:

$ flutter channel
Flutter channels:
  master
  dev
* beta
  stable

运行flutter channel dev可以切换至开发版,此时再运行flutter upgrade或者flutter upgrade --force即可进行更新。

你可能感兴趣的:(flutter)