Skip to content

Commit

Permalink
Create automated build
Browse files Browse the repository at this point in the history
  • Loading branch information
RRC_GHA committed Jan 30, 2024
1 parent c9a13ca commit 6103f47
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 182 deletions.
44 changes: 0 additions & 44 deletions public/2023-08-usgs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,50 +356,6 @@
"<span class='chapter-number'>4</span>  <span class='chapter-title'>Install R, RStudio and Git</span>"
]
},
{
"objectID": "session_05.html",
"href": "session_05.html",
"title": "5  R and GitHub Setup",
"section": "",
"text": "Learning Objectives",
"crumbs": [
"Week 2",
"<span class='chapter-number'>5</span>  <span class='chapter-title'>R and GitHub Setup</span>"
]
},
{
"objectID": "session_05.html#learning-objectives",
"href": "session_05.html#learning-objectives",
"title": "5  R and GitHub Setup",
"section": "",
"text": "Set global options in your .gitconfig file\nPractice how to set up GitHub Authentication using a Personal Access Token (PAT)",
"crumbs": [
"Week 2",
"<span class='chapter-number'>5</span>  <span class='chapter-title'>R and GitHub Setup</span>"
]
},
{
"objectID": "session_05.html#set-up-global-options-in-git",
"href": "session_05.html#set-up-global-options-in-git",
"title": "5  R and GitHub Setup",
"section": "5.1 Set up global options in Git",
"text": "5.1 Set up global options in Git\nBefore using Git, you need to tell it who you are, also known as setting the global options. To do this, we will be setting the global options in the Terminal.\n\n\n\n\n\n\nWhat’s the Terminal?\n\n\n\nTechnically, the Terminal is an interface for the shell, a computer program. To put that simply, we use the Terminal to tell a computer what to do. This is different from the Console in RStudio, which interprets R code and returns a value.\n\n\nTo get started, let’s open a new Terminal window in RStudio. Do this by clicking Tools &gt; Terminal &gt; New Terminal.\nA Terminal tab should now be open where your Console usually is.\n\n\n\n\n\n\nDon’t be afraid to dip your toes in the Terminal\n\n\n\nMost of our git operations will be done in RStudio, but there are some situations where you must work in the Terminal and use command line. It may be daunting to code in the Terminal, but as your comfort increases over time, you might find you prefer it. Either way, it’s beneficial to learn enough command line and to feel comfortable in the Terminal.\n\n\nLet’s start by adding your user name to the global options. Type the following into the command prompt, with your exact GitHub username, and press enter:\ngit config --global user.name \"my_user_name\"\n\n\nNote that if it ran successfully, it will look like nothing happened. We will check at the end to make sure it worked.\nNext, enter the following line, with the email address you used when you created your account on github.com:\ngit config --global user.email \"my_email@nceas.ucsb.edu\"\n\n\n\n\n\n\nCase and spelling matters!\n\n\n\nWhen you add your username and email to the global options you must use the exact same spelling and case that you used on GitHub otherwise, Git won’t be able to sync to your account.\n\n\nNext, we will set our credentials to not time out for a very long time. This is related to how our server operating system handles credentials - not doing this will make your Personal Access Token (PAT, which we will set up in the next section) expire immediately on the system, even though it is actually valid for at least a month.\ngit config --global credential.helper 'cache --timeout=10000000'\nNext, we will set the default branch name to main for any new repositories that are created moving forward. Why are we doing this? Previously, the default branch name was master and this racist terminology for git branches motivates us to update our default branch to main instead.\ngit config --global init.defaultBranch main\nFinally, check to make sure everything looks correct by entering this command, which will return the global options you have set.\ngit config --global --list",
"crumbs": [
"Week 2",
"<span class='chapter-number'>5</span>  <span class='chapter-title'>R and GitHub Setup</span>"
]
},
{
"objectID": "session_05.html#github-authentication",
"href": "session_05.html#github-authentication",
"title": "5  R and GitHub Setup",
"section": "5.2 GitHub Authentication",
"text": "5.2 GitHub Authentication\nGitHub recently deprecated password authentication for accessing repositories, so we need to set up a secure way to authenticate.\nThe book Happy Git and GitHub for the useR has a wealth of information related to working with Git in R, and these instructions are based off of Chapter 9 Personal access token for HTTPS.\nWe will be using a Personal Access Token (PAT) in this course. For better security and long term use, we recommend taking the extra steps to set up SSH keys (check out Chapter 10 Set up Keys for SSH).\n\n\n\n\n\n\nSetting up your PAT\n\n\n\n\nRun usethis::create_github_token() in the Console.\nA new browser window should open up to GitHub, showing all the scopes options. You can review the scopes, but you don’t need to worry about which ones to select this time. Using create_github_token() automatically pre-selects some recommended scopes. Go ahead and scroll to the bottom and click “Generate Token”.\nCopy the generated token.\nBack in RStudio, run gitcreds::gitcreds_set() in the Console.\nPaste your PAT when the prompt asks for it.\nLast thing, run usethis::git_sitrep() in the Console to check your Git configuration and that you’ve successful stored your PAT.\n\n\n\nCongrats! Now you’ve setup your authentication you should be able to work with GitHub in RStudio now.",
"crumbs": [
"Week 2",
"<span class='chapter-number'>5</span>  <span class='chapter-title'>R and GitHub Setup</span>"
]
},
{
"objectID": "session_06.html",
"href": "session_06.html",
Expand Down
141 changes: 4 additions & 137 deletions public/2023-08-usgs/session_05.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,6 @@
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
</style>


Expand Down Expand Up @@ -108,7 +74,7 @@
<link rel="stylesheet" href="style.css">
</head>

<body class="nav-sidebar floating slimcontent">
<body class="nav-sidebar floating">

<div id="quarto-search-results"></div>
<header id="quarto-header" class="headroom fixed-top quarto-banner">
Expand Down Expand Up @@ -233,117 +199,18 @@ <h1 class="title"><span class="chapter-number">5</span>&nbsp; <span class="chapt
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>

<ul>
<li><a href="#learning-objectives" id="toc-learning-objectives" class="nav-link active" data-scroll-target="#learning-objectives">Learning Objectives</a></li>
<li><a href="#set-up-global-options-in-git" id="toc-set-up-global-options-in-git" class="nav-link" data-scroll-target="#set-up-global-options-in-git"><span class="header-section-number">5.1</span> Set up global options in <code>Git</code></a></li>
<li><a href="#github-authentication" id="toc-github-authentication" class="nav-link" data-scroll-target="#github-authentication"><span class="header-section-number">5.2</span> GitHub Authentication</a></li>
</ul>
</nav>

</div>
<!-- main -->
<main class="content quarto-banner-title-block page-columns page-full" id="quarto-document-content">

<main class="content quarto-banner-title-block" id="quarto-document-content">




<section id="learning-objectives" class="level2 unnumbered">
<h2 class="unnumbered anchored" data-anchor-id="learning-objectives">Learning Objectives</h2>
<ul>
<li>Set global options in your <code>.gitconfig</code> file</li>
<li>Practice how to set up GitHub Authentication using a Personal Access Token (PAT)</li>
</ul>
</section>
<section id="set-up-global-options-in-git" class="level2 page-columns page-full" data-number="5.1">
<h2 data-number="5.1" class="anchored" data-anchor-id="set-up-global-options-in-git"><span class="header-section-number">5.1</span> Set up global options in <code>Git</code></h2>
<p>Before using <code>Git</code>, you need to tell it who you are, also known as setting the <strong>global options</strong>. To do this, we will be setting the global options in the Terminal.</p>
<div class="callout callout-style-default callout-caution no-icon callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon no-icon"></i>
</div>
<div class="callout-title-container flex-fill">
What’s the Terminal?
</div>
</div>
<div class="callout-body-container callout-body">
<p>Technically, the Terminal is an interface for the shell, a computer program. To put that simply, we use the Terminal to tell a computer what to do. This is different from the Console in RStudio, which interprets R code and returns a value.</p>
</div>
</div>
<p>To get started, let’s open a new Terminal window in RStudio. Do this by clicking Tools &gt; Terminal &gt; New Terminal.</p>
<p>A Terminal tab should now be open where your Console usually is.</p>
<div class="callout callout-style-default callout-caution no-icon callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon no-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Don’t be afraid to dip your toes in the Terminal
</div>
</div>
<div class="callout-body-container callout-body">
<p>Most of our <code>git</code> operations will be done in RStudio, but there are some situations where you must work in the Terminal and use command line. It may be daunting to code in the Terminal, but as your comfort increases over time, you might find you prefer it. Either way, it’s beneficial to learn <em>enough</em> command line and to feel comfortable in the Terminal.</p>
</div>
</div>
<p>Let’s start by adding your user name to the global options. Type the following into the command prompt, with your <strong>exact</strong> GitHub username, and press enter:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> config <span class="at">--global</span> user.name <span class="st">"my_user_name"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>

<div class="no-row-height column-margin column-container"><div class="">
<p>Note that <strong>if it ran successfully, it will look like nothing happened</strong>. We will check at the end to make sure it worked.</p>
</div></div><p>Next, enter the following line, with the email address you used when you created your account on <a href="https://github.com/">github.com</a>:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> config <span class="at">--global</span> user.email <span class="st">"my_email@nceas.ucsb.edu"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Case and spelling matters!
</div>
</div>
<div class="callout-body-container callout-body">
<p>When you add your username and email to the global options you <strong>must</strong> use the exact same spelling and case that you used on GitHub otherwise, <code>Git</code> won’t be able to sync to your account.</p>
</div>
</div>
<p>Next, we will set our credentials to not time out for a very long time. This is related to how our server operating system handles credentials - not doing this will make your Personal Access Token (PAT, which we will set up in the next section) expire immediately on the system, even though it is actually valid for at least a month.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> config <span class="at">--global</span> credential.helper <span class="st">'cache --timeout=10000000'</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>Next, we will set the default branch name to <code>main</code> for any new repositories that are created moving forward. Why are we doing this? Previously, the default branch name was <code>master</code> and this racist terminology for <code>git</code> branches motivates us to update our default branch to <code>main</code> instead.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> config <span class="at">--global</span> init.defaultBranch main</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>Finally, check to make sure everything looks correct by entering this command, which will return the global options you have set.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> config <span class="at">--global</span> <span class="at">--list</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section>
<section id="github-authentication" class="level2" data-number="5.2">
<h2 data-number="5.2" class="anchored" data-anchor-id="github-authentication"><span class="header-section-number">5.2</span> GitHub Authentication</h2>
<p>GitHub recently deprecated password authentication for accessing repositories, so we need to set up a secure way to authenticate.</p>
<p>The book <a href="https://happygitwithr.com/index.html">Happy Git and GitHub for the useR</a> has a wealth of information related to working with <code>Git</code> in R, and these instructions are based off of <a href="https://happygitwithr.com/https-pat.html">Chapter 9 Personal access token for HTTPS</a>.</p>
<p>We will be using a <strong>Personal Access Token (PAT)</strong> in this course. For better security and long term use, we recommend taking the extra steps to set up SSH keys (check out <a href="https://happygitwithr.com/ssh-keys.html">Chapter 10 Set up Keys for SSH</a>).</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Setting up your PAT
</div>
</div>
<div class="callout-body-container callout-body">
<ol type="1">
<li>Run <code>usethis::create_github_token()</code> in the Console.</li>
<li>A new browser window should open up to GitHub, showing all the scopes options. You can review the scopes, but you don’t need to worry about which ones to select this time. Using <code>create_github_token()</code> automatically pre-selects some recommended scopes. <strong>Go ahead and scroll to the bottom and click “Generate Token”</strong>.</li>
<li>Copy the generated token.</li>
<li>Back in RStudio, run <code>gitcreds::gitcreds_set()</code> in the Console.</li>
<li>Paste your PAT when the prompt asks for it.</li>
<li>Last thing, run <code>usethis::git_sitrep()</code> in the Console to check your <code>Git</code> configuration and that you’ve successful stored your PAT.</li>
</ol>
</div>
</div>
<p>Congrats! Now you’ve setup your authentication you should be able to work with GitHub in RStudio now.</p>
<!-- -->


</section>

</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
Expand Down
2 changes: 1 addition & 1 deletion public/2023-08-usgs/site_libs/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

0 comments on commit 6103f47

Please sign in to comment.