Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you force 'pub get' to get latest from git?

Tags:

flutter

dart

I have a git dependency in my pubspec.yaml file, how can I force it to be updated when new changes occur in the git repo?

flutter pub get / pub get

It does not get the latest, as it is in .pub-cache/git/

Is there a way to force a specific dependency to update from a git repo referenced in pubspec.yaml?

like image 426
Chris G. Avatar asked Nov 26 '18 15:11

Chris G.


People also ask

How do I upgrade a specific package in flutter?

To upgrade to a new version of the package, for example to use new features in that package, run flutter pub upgrade (Upgrade dependencies in IntelliJ or Android Studio) to retrieve the highest available version of the package that is allowed by the version constraint specified in pubspec. yaml .

How do I reset my github repository?

Only do a hard reset if you are the only using the remote repository, or if you haven't yet pushed the commits you're going to drop. Find the commit hash of the commit you want to reset to with git log . Perform the local hard reset by running git reset --hard <commit-hash> .

Does not appear to be a git repo?

The “… does not a appear to be a git repository” error is triggered when you try to clone, or run other commands, in a directory that is not recognized as a Git repository. The directory or remote file path might not have initialized Git, or the file path you are trying to access as an active repository is incorrect.


2 Answers

In your pubspec.yaml, you can specify a particular git commit:

dependencies:
  http2:
    git:
      url: https://github.com/dart-lang/http2.git
      ref: c31df28c3cf076c9aacaed1d77f45b66bb2e01a6

Or if you specify only a branch in "ref":

dependencies:
  http2:
    git:
      url: https://github.com/dart-lang/http2.git
      ref: master

You need to force the update with flutter packages upgrade

like image 141
Xavier Avatar answered Nov 15 '22 19:11

Xavier


Use

flutter packages upgrade

to get latest.

flutter packages get

only gets latests the first time and writes the resolved versions into pubspec.lock Subsequent flutter packages get runs then try to get the versions listed in pubspec.lock,
while flutter packages upgrade always ignores pubspec.lock

like image 43
Günter Zöchbauer Avatar answered Nov 15 '22 20:11

Günter Zöchbauer