rgitbitbucket-serverpersonal-access-token

how do you install R packages from a private git repo with a PAT?


I am trying to install an R package from a private git repository hosted on my employer's internal Bitbucket server.

I have had success using remotes::install_git() for other projects on public servers in the past however for this specific project I need to connect to the repository via an HTTPS url and use a personal access token (PAT) to authenticate. The remotes::install_git() documentation includes an entry for adding credentials, but the documentation for this option is sparse. There is a lot of documentation for remotes::install_github(), but as this is not a github hosted repository, many of the suggestions there do not seem to work.


Solution

  • My go to :

    gitcred <- git2r::cred_user_pass(username="$(USERNAME)",password="$(PAT)")
    #here you can put any private repo such as devops azure or bitbucket, etc..
    remotes::install_git("https://dev.azure.com/XXX", credentials = gitcred)'