Skip to content

Commit 8e526d9

Browse files
committed
spacing in code comments
1 parent 2f66125 commit 8e526d9

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

_freeze/index/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"hash": "1e06a3f41c0a24d0381eb4b0d28756f8",
2+
"hash": "4bebeffc8c0f8059f7b80b312910db3c",
33
"result": {
44
"engine": "knitr",
5-
"markdown": "---\ntitle: \"Git, GitHub & RStudio\"\ndescription: RStudio users can leverage git Version-control which enhances 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## Background\n\nThis page gives tips on the procedures of configuring Git and GitHub from withing RStudio. The page favors the brevity of highlighting functions in a procedural order. There are also three videos in the sidebar (ranging from 3 minutes to 120 minutes) . The last video explains in more detail why and how you use version control as part of your reproducible workflow.\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\nNote: Check to see if you already have git on your local workstation. You can do this by running `system(\"git --version\")` in the RStudio console. Often, windows users must first manually install [Git](https://git-scm.com/downloads).\n\n## Tips\n\n### Configure git and manage GitHub credentials (PAT)\n\nThe following are steps you can inovke **in your RStudio IDE** to securely connect your RStudio instance to GitHub. I **recommend** invoking these functions **in the RStudio console**. The steps in the code chunk below only need to be inovked once per RStudio instance, per active Personal Access Tokens (PAT.) **First, Log in to GitHub**, then it is easy to create new GitHub PATs from the RStudio console: `usethis::create_github_token()`.\n\nBy default Personal Access Tokens (PATs) expire every 30 days. GitHub tokens (PATs) can be managed at the [GitHub developer page](https://github.com/settings/apps).\n\n::: column-margin\n<iframe width=\"300\" height=\"200\" 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\n::: callout-note\nIf this is your first time, you will probably need to run `usethis::use_git_config()`. Typically the process of setting your git configuration with your GitHub ID and associated email is only done once, i.e. the first time.\n\nBy contrast, you will need to rerun `usethis::create_github_token()` each time a PAT expires.\n:::\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() # generates a PAT token you can copy/paste in the next step.\ngitcreds::gitcreds_set() # paste the PAT from the previous step\n\n# Now check that your git credentials are set. \n# Check whether you have confgigured your git user.name and user.email. If not, use usethis::use_git_config()\ngh::gh_whoami()\nusethis::gh_token_help()\nusethis::use_git_config(user.name = \"Jane Doe\", user.email = \"jane@example.com\")\nusethis::gh_token_help()\n```\n:::\n\n\n### Create a new RStudio Project\n\nIt's recommended to use RStudio to create your local git repository. With this method, after selecting a \"[New RStudio Project (Directions)](https://intro2r.library.duke.edu/proj.html#rstudio-projects1)\", **select the \"Create a git repository\" option**. This will ensure your RStudio project is properly configured as a git repository. Then, add a README file and a license, before connecting your local repository to GitHub.\n\n::: column-margin\n<iframe width=\"300\" height=\"200\" src=\"https://www.youtube.com/embed/videoseries?si=hWO26jfu4-ctXAE1&amp;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\n\n::: {.cell}\n\n```{.r .cell-code}\nuse_readme.md()\nuse_ccby_license() # Optionally, add a license\n\n# Before next step → stage & commit changes\nuse_github() # Connect local repo to GitHub\n```\n:::\n\n\n### Alternatively, transform an existing folder\n\nOn your local workstation, you can transform a local folder into an RStudio project and also make that project a git repository. Then connect the local repository to GitHub.\n\nThis will transform the local folder into an RStudio project. Howver, with this approach you must then create local git repository and then connect that repo to GitHub from local.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(usethis)\n\nuse_git() # initialize a git repo\n# use_git_ignore() The .gitignore file is created by default running use_git()\nuse_readme.md()\nuse_ccby_license() # Optionally, add a license\n\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::: column-margin\n<iframe width=\"300\" height=\"200\" 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\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## 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",
5+
"markdown": "---\ntitle: \"Git, GitHub & RStudio\"\ndescription: RStudio users can leverage git Version-control which enhances 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## Background\n\nThis page gives tips on the procedures of configuring Git and GitHub from withing RStudio. The page favors the brevity of highlighting functions in a procedural order. There are also three videos in the sidebar (ranging from 3 minutes to 120 minutes) . The last video explains in more detail why and how you use version control as part of your reproducible workflow.\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\nNote: Check to see if you already have git on your local workstation. You can do this by running `system(\"git --version\")` in the RStudio console. Often, windows users must first manually install [Git](https://git-scm.com/downloads).\n\n## Tips\n\n### Configure git and manage GitHub credentials (PAT)\n\nThe following are steps you can inovke **in your RStudio IDE** to securely connect your RStudio instance to GitHub. I **recommend** invoking these functions **in the RStudio console**. The steps in the code chunk below only need to be inovked once per RStudio instance, per active Personal Access Tokens (PAT.) **First, Log in to GitHub**, then it is easy to create new GitHub PATs from the RStudio console: `usethis::create_github_token()`.\n\nBy default Personal Access Tokens (PATs) expire every 30 days. GitHub tokens (PATs) can be managed at the [GitHub developer page](https://github.com/settings/apps).\n\n::: column-margin\n<iframe width=\"300\" height=\"200\" 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\n::: callout-note\nIf this is your first time, you will probably need to run `usethis::use_git_config()`. Typically the process of setting your git configuration with your GitHub ID and associated email is only done once, i.e. the first time.\n\nBy contrast, you will need to rerun `usethis::create_github_token()` each time a PAT expires.\n:::\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() # generates a PAT token you can copy/paste in the next step.\ngitcreds::gitcreds_set() # paste the PAT from the previous step\n\n# Now check that your git credentials are set. \n# Check whether you have confgigured your git user.name and user.email. \n# If not, use usethis::use_git_config()\ngh::gh_whoami()\nusethis::gh_token_help()\nusethis::use_git_config(user.name = \"Jane Doe\", user.email = \"jane@example.com\")\nusethis::gh_token_help()\n```\n:::\n\n\n### Create a new RStudio Project\n\nIt's recommended to use RStudio to create your local git repository. With this method, after selecting a \"[New RStudio Project (Directions)](https://intro2r.library.duke.edu/proj.html#rstudio-projects1)\", **select the \"Create a git repository\" option**. This will ensure your RStudio project is properly configured as a git repository. Then, add a README file and a license, before connecting your local repository to GitHub.\n\n::: column-margin\n<iframe width=\"300\" height=\"200\" src=\"https://www.youtube.com/embed/videoseries?si=hWO26jfu4-ctXAE1&amp;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\n\n::: {.cell}\n\n```{.r .cell-code}\nuse_readme.md()\nuse_ccby_license() # Optionally, add a license\n\n# Before next step → stage & commit changes\nuse_github() # Connect local repo to GitHub\n```\n:::\n\n\n### Alternatively, transform an existing folder\n\nOn your local workstation, you can transform a local folder into an RStudio project and also make that project a git repository. Then connect the local repository to GitHub.\n\nThis will transform the local folder into an RStudio project. Howver, with this approach you must then create local git repository and then connect that repo to GitHub from local.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(usethis)\n\nuse_git() # initialize a git repo\n# use_git_ignore() The .gitignore file is created by default running use_git()\nuse_readme.md()\nuse_ccby_license() # Optionally, add a license\n\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::: column-margin\n<iframe width=\"300\" height=\"200\" 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\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## 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",
66
"supporting": [],
77
"filters": [
88
"rmarkdown/pagebreak.lua"

_site/index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,12 @@ <h3 class="anchored" data-anchor-id="configure-git-and-manage-github-credentials
281281
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>gitcreds<span class="sc">::</span><span class="fu">gitcreds_set</span>() <span class="co"># paste the PAT from the previous step</span></span>
282282
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a></span>
283283
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Now check that your git credentials are set. </span></span>
284-
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="co"># Check whether you have confgigured your git user.name and user.email. If not, use usethis::use_git_config()</span></span>
285-
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a>gh<span class="sc">::</span><span class="fu">gh_whoami</span>()</span>
286-
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>usethis<span class="sc">::</span><span class="fu">gh_token_help</span>()</span>
287-
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>usethis<span class="sc">::</span><span class="fu">use_git_config</span>(<span class="at">user.name =</span> <span class="st">"Jane Doe"</span>, <span class="at">user.email =</span> <span class="st">"jane@example.com"</span>)</span>
288-
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>usethis<span class="sc">::</span><span class="fu">gh_token_help</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
284+
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="co"># Check whether you have confgigured your git user.name and user.email. </span></span>
285+
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="co"># If not, use usethis::use_git_config()</span></span>
286+
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>gh<span class="sc">::</span><span class="fu">gh_whoami</span>()</span>
287+
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>usethis<span class="sc">::</span><span class="fu">gh_token_help</span>()</span>
288+
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>usethis<span class="sc">::</span><span class="fu">use_git_config</span>(<span class="at">user.name =</span> <span class="st">"Jane Doe"</span>, <span class="at">user.email =</span> <span class="st">"jane@example.com"</span>)</span>
289+
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a>usethis<span class="sc">::</span><span class="fu">gh_token_help</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
289290
</div>
290291
</section>
291292
<section id="create-a-new-rstudio-project" class="level3 page-columns page-full">

0 commit comments

Comments
 (0)