Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Sep 2, 2024
1 parent 027703f commit 459db1b
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3b08e052
fd75c087
117 changes: 80 additions & 37 deletions schedule/slides/00-version-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
<h2>00 Git, Github, and Slack</h2>
<p><span class="secondary">Stat 406</span></p>
<p><span class="secondary">Geoff Pleiss, Trevor Campbell</span></p>
<p>Last modified – 29 August 2024</p>
<p>Last modified – 02 September 2024</p>
<p><span class="math display">\[
\DeclareMathOperator*{\argmin}{argmin}
\DeclareMathOperator*{\argmax}{argmax}
Expand Down Expand Up @@ -475,6 +475,23 @@ <h2>Why these?</h2>
<section id="git-and-github" class="title-slide slide level1 center">
<h1>Git and GitHub</h1>

</section>
<section class="slide level2">

<p><em>But I already know how to use git/Github…</em></p>
<p>Are you sure?</p>
<ul>
<li>Have you used git/Github in a professional team context?</li>
<li>Do you follow a proper pull request workflow?</li>
<li>Do you know what files to track and not to track?</li>
<li>Can you get yourself unstuck from common problems?</li>
</ul>
<div class="fragment">
<p><br></p>
<p><em>Yes. I really know how to use git/Github.</em></p>
<p>Then pull out your laptop and read my <a href="https://geoffpleiss.com/git_wizard.pdf">“How To Be a Git Wizard”</a> slides.<br>
I guarantee (with 99% confidence) that you will learn a new command.</p>
</div>
</section>
<section id="why-version-control" class="slide level2">
<h2>Why version control?</h2>
Expand Down Expand Up @@ -660,8 +677,11 @@ <h2>What should be tracked?</h2>
<p><strong>TLDR</strong></p>
<p>Any file that <span class="secondary">YOU</span> edit should be tracked<br>
Any file that’s <span class="secondary">computer generated</span> should PROBABLY NOT be tracked</p>
<p><span class="small">However, in this course you will track rendered PDFs of your homeworks/labs. This makes it easier for the graders.</span></p>
</div>
<div class="fragment">
</section>
<section id="what-should-be-tracked-2" class="slide level2">
<h2>What should be tracked?</h2>
<p>A file called <code>.gitignore</code> tells <code>git</code> files or types to never track</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode numberSource markdown number-lines code-with-copy"><code class="sourceCode markdown"><span id="cb6-1"><a></a><span class="in">```{bash}</span></span>
<span id="cb6-2"><a></a><span class="in"># History files</span></span>
Expand All @@ -679,11 +699,6 @@ <h2>What should be tracked?</h2>
<span id="cb6-14"><a></a><span class="in">*.so</span></span>
<span id="cb6-15"><a></a><span class="in">*.DS_Store</span></span>
<span id="cb6-16"><a></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="what-should-be-tracked-2" class="slide level2">
<h2>What should be tracked?</h2>
<p><br></p>
<p>Shortcut to track everything (use carefully):</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode numberSource markdown number-lines code-with-copy"><code class="sourceCode markdown"><span id="cb7-1"><a></a><span class="in">```{bash}</span></span>
<span id="cb7-2"><a></a><span class="in">git add .</span></span>
Expand Down Expand Up @@ -734,14 +749,6 @@ <h2>Some things to be aware of</h2>
<li>See Chapter 13 if RStudio can’t find <code>git</code></li>
</ol></li>
</ul>
</section>
<section id="if-you-know-all-this-already" class="slide level2">
<h2>If you know all this already…</h2>
<p><br></p>
<div class="center">
<p>Check out my <a href="https://geoffpleiss.com/git_wizard.pdf">“How To Be a Git Wizard”</a> slides to take your git game to the next level.<br>
I guarantee (with 99% confidence) that you will learn an amazing new command.</p>
</div>
<!--
## The `main/develop/branch` workflow
Expand Down Expand Up @@ -778,7 +785,12 @@ <h2>Guardrails</h2>
<li>PR templates: Little admonitions when you open a PR</li>
<li>Branch protection: prevent you from doing stuff</li>
</ol></li>
<li><p>In this course, we protect <code>main</code> so that you can’t push there</p></li>
</ul>
</section>
<section id="guardrails-1" class="slide level2">
<h2>Guardrails</h2>
<ul>
<li>Real-world repos often protect <code>main</code> so that you can’t push there</li>
</ul>
<div class="callout callout-warning callout-titled callout-style-default">
<div class="callout-body">
Expand All @@ -789,19 +801,27 @@ <h2>Guardrails</h2>
<p><strong>Warning</strong></p>
</div>
<div class="callout-content">
<p>If you try to push to <code>main</code>, it will give an error like</p>
<p>You’d see an error like this:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode numberSource markdown number-lines code-with-copy"><code class="sourceCode markdown"><span id="cb8-1"><a></a><span class="in">```{bash}</span></span>
<span id="cb8-2"><a></a><span class="in">remote: error: GH006: Protected branch update failed for refs/heads/main.</span></span>
<span id="cb8-3"><a></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>The fix is: make a new branch, then push that.</p>
</div>
</div>
</div>
<div class="fragment">
<ul>
<li><p>Unfortunately, we can’t set up those protections for this course. Github recently put these protections behind a paywall :(</p></li>
<li><p>So now it’s your responsibility. Please don’t push to <code>main</code>!</p></li>
</ul>
</div>
</section>
<section class="slide level2">

<section id="guardrails-2" class="slide level2">
<h2>Guardrails</h2>
<div class="flex">
<div class="w-40">
<ul>
<li>I also use a PR template. It gives you some instructions that you should follow</li>
<li>We have a PR template on the homework and lab repos. It gives you some instructions that you should follow</li>
</ul>
<div class="callout callout-important callout-titled callout-style-default">
<div class="callout-body">
Expand All @@ -816,6 +836,15 @@ <h2>Guardrails</h2>
</div>
</div>
</div>
</div>
<div class="w-60">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="gfx/pr_template.png" class="quarto-figure quarto-figure-center" alt="PR Template"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="operations-in-rstudio" class="slide level2">
<h2>Operations in Rstudio</h2>
Expand Down Expand Up @@ -1017,32 +1046,46 @@ <h2>How to undo in 3 scenarios</h2>
<section id="recovering-from-things" class="slide level2">
<h2>Recovering from things</h2>
<ol type="1">
<li>Accidentally did work on main, Tried to Push but got refused</li>
<li>Accidentally did work on main (locally), but didn’t push to Github</li>
</ol>
<div class="sourceCode" id="cb21"><pre class="sourceCode numberSource markdown number-lines code-with-copy"><code class="sourceCode markdown"><span id="cb21-1"><a></a><span class="in">```{bash}</span></span>
<span id="cb21-2"><a></a><span class="in"># make a new branch with everything, but stay on main</span></span>
<span id="cb21-3"><a></a><span class="in">git branch newbranch</span></span>
<span id="cb21-4"><a></a><span class="in"># find out where to go to</span></span>
<span id="cb21-5"><a></a><span class="in">git log</span></span>
<span id="cb21-6"><a></a><span class="in"># undo everything after ace2193</span></span>
<span id="cb21-7"><a></a><span class="in">git reset --hard ace2193</span></span>
<span id="cb21-8"><a></a><span class="in">git checkout newbranch</span></span>
<span id="cb21-9"><a></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span id="cb21-2"><a></a><span class="in">git branch newbranch # make a new branch with everything, but stay on main</span></span>
<span id="cb21-3"><a></a><span class="in">git fetch &amp;&amp; git reset --hard origin/main # undo everything up to the last commit on Github's main branch</span></span>
<span id="cb21-4"><a></a><span class="in">git checkout newbranch # switch to new branch</span></span>
<span id="cb21-5"><a></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<ol start="2" type="1">
<li>Made a branch, did lots of work, realized it’s trash, and you want to burn it</li>
<li>Accidentally did work on main (locally), and pushed to Github<br>
<span class="small">(PLEASE PLEASE PLEASE don’t do this, but if you do…)</span></li>
</ol>
<div class="sourceCode" id="cb22"><pre class="sourceCode numberSource markdown number-lines code-with-copy"><code class="sourceCode markdown"><span id="cb22-1"><a></a><span class="in">```{bash}</span></span>
<span id="cb22-2"><a></a><span class="in">git checkout main</span></span>
<span id="cb22-3"><a></a><span class="in">git branch -d badbranch</span></span>
<span id="cb22-4"><a></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span id="cb22-2"><a></a><span class="in">git branch newbranch # make a new branch with everything, but stay on main</span></span>
<span id="cb22-3"><a></a><span class="in"># NOTE: we can't use reset, because the commits are already published!</span></span>
<span id="cb22-4"><a></a><span class="in"># You can't delete commits from Github once they've been pushed.</span></span>
<span id="cb22-5"><a></a><span class="in"># We instead have to create and push a series of "reverse" commits</span></span>
<span id="cb22-6"><a></a><span class="in"># that undo the commits we pushed, and then push those undo commits</span></span>
<span id="cb22-7"><a></a><span class="in">git fetch &amp;&amp; git revert origin/main..HEAD # note the different command here!</span></span>
<span id="cb22-8"><a></a><span class="in">git push origin main</span></span>
<span id="cb22-9"><a></a><span class="in"># Now we can go to the new branch (without the undo commits)</span></span>
<span id="cb22-10"><a></a><span class="in">git checkout newbranch # Switch to new branch</span></span>
<span id="cb22-11"><a></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section>
<section id="recovering-from-things-1" class="slide level2">
<h2>Recovering from things</h2>
<ol start="3" type="1">
<li><p>Anything more complicated, either post to Slack or LMGTFY</p></li>
<li><p>In the Lab next week, you’ll practice</p>
<li>Made a branch, did lots of work, realized it’s trash, and you want to burn it</li>
</ol>
<div class="sourceCode" id="cb23"><pre class="sourceCode numberSource markdown number-lines code-with-copy"><code class="sourceCode markdown"><span id="cb23-1"><a></a><span class="in">```{bash}</span></span>
<span id="cb23-2"><a></a><span class="in">git checkout main</span></span>
<span id="cb23-3"><a></a><span class="in">git branch -D badbranch</span></span>
<span id="cb23-4"><a></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<ol start="4" type="1">
<li><p>Anything more complicated, post to Slack or come to office hours</p></li>
<li><p>In the Lab next week, you’ll practice</p></li>
</ol>
<ul>
<li>Doing it right.</li>
<li>Recovering from some mistakes.</li>
</ul></li>
</ol>
</ul>
</section></section>
<section id="example-of-setting-up-labs" class="title-slide slide level1 center">
<h1>Example of setting up labs</h1>
Expand Down
Binary file added schedule/slides/gfx/pr_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 459db1b

Please sign in to comment.