Reputation: 3992
[Env: RStudio Version 1.4.1106, R version 4.0.2]
Since github disallowed authentication via userid/password, I've had problems pushing project updates from RStudio.
I setup a github PAT and installed this in .renviron
GITHUB_PAT=ghp.....
Checking, using usethis::sitrep()
, it all looks OK, AFAICS: says 'Personal access token "discovered"'
> usethis::git_sitrep()
Git config (global)
* Name: 'Michael Friendly'
* Email: '[email protected]'
* Vaccinated: TRUE
i Defaulting to 'https' Git protocol
* Default Git protocol: 'https'
GitHub
* Default GitHub host: 'https://github.com'
* Personal access token for 'https://github.com': '<discovered>'
* GitHub user: 'friendly'
* Token scopes: 'gist, repo, user, workflow'
* Email(s): '[email protected] (primary)', '[email protected]'
Git repo for current project
* Active usethis project: 'C:/R/Projects/HistDataVis'
* Default branch: 'main'
* Current local branch -> remote tracking branch:
'main' -> 'origin/main'
GitHub remote configuration
* Type = 'ours'
* Host = 'https://github.com'
* Config supports a pull request = TRUE
* origin = 'friendly/HistDataVis' (can push)
* upstream = <not configured>
* Desc = 'origin' is both the source and primary repo.
Read more about the GitHub remote configurations that usethis supports at:
'https://happygitwithr.com/common-remote-setups.html'
>
Yet, when I try to push to github, I'm prompted with a userid/password dialog, which fails because github rejects password authentication.
Further checking: GITHUB_PAT
seems to be OK,
> Sys.getenv("GITHUB_PAT")
[1] "ghp_T..."
>
What could be wrong? How can I test this otherwise? What can I do to fix this?
Upvotes: 1
Views: 1516
Reputation: 670
I haven't got around to doing this globally, yet, but this works on a repo-by-repo basis
git remote set-url origin [email protected]:username/repo.git
in the project's .git directory. (Not at all obvious.)
Upvotes: 1