To update the shared slides for Data Science Learning Community book clubs (or to participate in other open source projects), you need to set up GitHub. These instructions should help you get started.
If you have questions about this process, ask in the #help-zzz-github_open_ource channel on the Data Science Learning Community Slack.
-
Install git. This is highly system dependent, so we recommend following the instructions in Happy Git and GitHub for the useR.
-
Install the {usethis} and {devtools} packages:
install.packages(c("usethis", "devtools"))
-
library(usethis)
. -
Run
use_git_config(user.name = "Your Fullname", user.email = "your_email@yourplace.cool")
-
Run
usethis::git_sitrep()
to see what steps you need to do. Read the errors and warnings carefully, and follow the instructions provided. We'll continue with instructions that work if you've never set up GitHub in RStudio before, or if you've set it up incorrect (eg, you get the error "Token lacks recommended scopes"). -
As recommended, run
usethis::create_github_token(description = "rstudio")
(thedescription
argument can be whatever you want, just something to remember what you use that token for). The call should open a browser tab on which you can create a token with the recommended settings. You may have to login to GitHub to get to the expected page. Set the expiration of the token to whatever makes sense for you (ie, balance security vs how often you'll have to repeat this step). -
Click "Generate token" (green button at the bottom of that page).
-
Be sure to copy the token. It should look something like this:
ghp_ABunchOfLettersAndNumbers
. You must copy it right now, you won't get another chance (but you can always delete the token and try again if you make a mistake). -
Call
gitcreds::gitcreds_set()
to register this token in the local Git credential store. If you already have a token stored, you'll be asked if you want to keep, replace, or see those credentials. Choose "Replace these credentials". -
Paste the token you copied above when asked for a token or password.
-
Re-run
usethis::git_sitrep()
. If you have any more errors, resolve them as suggested by that call. We'll continue with the most likely situation. Re-run this each time you make a change, until it doesn't give any errors or warnings. -
Call
usethis::git_vaccinate()
. This function "vaccinates" your system against common git safety issues, such as accidentally sharing passwords. -
(optional) Set up a default {usethis} directory:
usethis::edit_r_profile()
to open your profile for editing.- Add this line: options(usethis.destdir = "YOURDIR") (replace YOURDIR with the root directory under which you want your R projects to appear).
- Restart your R session (Session/Restart R in Rstudio).
- Run
getOption("usethis.destdir")
to make sure it shows what you expect.
- When you work on a book club or other project, use
usethis::create_from_github()
to set up a new RStudio project. For example,usethis::create_from_github("r4ds/bookclub-setup")
creates an RStudio project for this repository.
We recommend using the {usethis} pull request helpers for all work on DSLC repositories. Please reach out for help if you have any questions!