"markdown": "---\ntitle: \"Git, GitHub & RStudio\"\ndescription: RStudio users can leverage git Version control to enhance reproducibility.\n---\n\n\nThe [`usethis`](https://usethis.r-lib.org/) package and the RStudio IDE will help you orchestrate your version control repositories as RStudio projects.\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/r5_v5f6128M\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen>\n\n</iframe>\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/videoseries?si=hWO26jfu4-ctXAE1&list=PLXsA_OlR0o0PcuagC_TUl32RULZkLHI1D\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen>\n\n</iframe>\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/VjDM-XsoHUQ\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen>\n\n</iframe>\n\n### Setup\n\nTo 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](https://usethis.r-lib.org/articles/articles/usethis-setup.html), and [Managing Git(Hub) Credentials](https://usethis.r-lib.org/articles/articles/git-credentials.html).\n\n### Tips\n\n#### Clone or fork from GitHub\n\n\n::: {.cell}\n\n```{.r .cell-code}\nusethis::create_from_github(\"https://github.com/data-and-visualization/git-tutorial\")\n```\n:::\n\n\n#### Create the GitHub repo from local\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(usethis)\nuse_git() # initialize a git repo\nuse_git_ignore()\nuse_readme.Rmd()\nuse_ccby_license()\n# Before next step → stage & commit changes\nuse_github() # Connect local repo to GitHub\n```\n:::\n\n\n#### Rename default branch\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(usethis)\ngit_default_branch()\ngit_default_branch_rename()\ngit_default_branch_rediscover()\n```\n:::\n\n\n#### set-up git and manage GitHub credentials\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Sign-in to your GitHub account\n# Read: https://usethis.r-lib.org/articles/articles/git-credentials.html\n# Read: https://usethis.r-lib.org/articles/articles/usethis-setup.html\nusethis::create_github_token()\ngitcreds::gitcreds_set()\ngh::gh_whoami()\nusethis::gh_token_help()\nusethis::use_git_config(user.name = \"Jane Doe\", user.email = \"
[email protected]\")\nusethis::gh_token_help()\n```\n:::\n\n\n### Next Level...\n\nTake your reproducibility to the next level. [Make your code citable](https://guides.github.com/activities/citable-code/) by connecting your GitHub repo and your [ORCID](https://orcid.org/register) (unique author ID) through to the [Zenodo](https://zenodo.org/) archival repository. Now, every time you commit a milestone release, you also mint a DOI.\n\n#### Share a zero-install compute environment\n\nPublish your code in a binder.org container\n\n- Full documentation to create a sharable RStudio compute environment is [documented on this Quarto page about projects](https://quarto.org/docs/projects/binder.html).\n\n- The key elements are an `install.R` and `runtime.txt` files. The content and format of each file is demonstrated properly at the GitHub repo. Browse and you will see.\n\n- In summary, at the Terminal, type: `quarto use binder`\n\n##### Hints\n\nGenerate a binder badge with `usethis::use_binder_badge(urlpath = \"rstudio\")`. This should store the badge in your GitHub's project `README` file. Then `commit` and `push` your changes to GitHub; go to the README on GitHub, launch the build and wait for the long launch/build time.\n\nHint: be prepared to wait. The first build can take some time. Sometimes you must launch an initial or dormant build more than once. In my experienced these hiccups are rare, but try the launch twice before getting involved in extensive troubleshooting.\n\n------------------------------------------------------------------------\n\n*The old documentation from this site can be found in the [v.0.2019 release](https://github.com/data-and-visualization/git-tutorial/releases/tag/v0.9.2019) on GitHub*.\n",
0 commit comments