Git, GitHub & RStudio

Makin’ it work!!

The usethis package and the RStudio IDE will help you orchestrate your version control repositories as RStudio projects.

Setup

To get started, make a free GitHub.com account. Make sure you have the latest versions of R, RStudio, and usethis. Then, setup your RStudio configuration using two key documents: Setup, and Managing Git(Hub) Credentials.

Tips

Clone or fork from GitHub

usethis::create_from_github("https://github.com/data-and-visualization/git-tutorial")

Create the GitHub repo from local

library(usethis)
use_git()          # initialize a git repo
use_git_ignore()
use_readme.Rmd()
use_ccby_license()
use_github()       # Connect local repo to GitHub

set-up git and manage GitHub credentials

# Sign-in to your GitHub account
# Read: https://usethis.r-lib.org/articles/articles/git-credentials.html
# Read: https://usethis.r-lib.org/articles/articles/usethis-setup.html
usethis::create_github_token()
gitcreds::gitcreds_set()
gh::gh_whoami()
usethis::git_sitrep()
usethis::use_git_config(user.name = "Jane Doe", user.email = "jane@example.com")
gh::git_sitrep()

Next Level…

Take your reproducibility to the next level. Make your code citable by connecting your GitHub repo and your ORCID (unique author ID) through to the Zenodo archival repository. Now, every time you commit a milestone release, you also mint a DOI.

Containerize your repository with binder.org using the holepunch package.

Publish your code in a binder.org container

Use the holepunch package


The old documentation from this site can be found in the v.0.2019 release on GitHub.

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. Source code is available at https://github.com/data-and-visualization/git-tutorial, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".