How can I add a private package from GitHub with my user and password to my pubspec.yaml?

Viewed 1712

My question is simple. I can clone a private git repository using

git clone https://my_user_name:my_password@github.com/my_account/my_package.git

now, How can I add a private package from GitHub with my user and password to my pubspec.yaml?

dependencies:
  my_package:
    git: https://my_user_name:my_password@github.com/my_account/my_package.git 

In my case, I am working with Flutter/Dart in IntelliJ IDEA. But assume the solution should work on any environment and other programming languages.

1 Answers

Finally, after test and test and test... found two good things:

First: We can use

dependencies:
  my_package:
    git: 
      url: https://my_user_name:my_password@github.com/my_account/my_package.git 
      ref: stable
      # ref: master or any other branch in your private package.

and with ref: we can select any branch by name.

Related