How to link a scaffolded project with github


#1

Hi,

Very basic question regarding the usethis package/github

How would I link a package created using the command usethis::create_package() with a repository on github. My normal workflow is to create a repository on github first and then create a new project from github in the IDE

Thanks,

Iain


#2

You can use the function usethis::use_github to help you with that. it will use the github API to create a repo in github and push your local git repo there. You can use usethis::use_git to add your project with git.

The workflow of having an existing project and create the github repo last is explained in this chapter of happygitwithr book:

It is an awesome resource by @jennybryan about Git, Github, R and RStudio.

Know that currently there is a workshop at RStudio Conf that talked about it. Here is a great blog post that present some notes and mentioned this too:


#3

Perfect, thanks!

The following steps seemed to work
usethis::edit_r_environ() - to set GITHUB_PAT = ‘token’ from https://github.com/settings/tokens
usethis::create_package(‘test’)
usethis::git()
usethis::github()