final version of presentation

main
will king 2 years ago
parent c78c9743a0
commit 5fd1467fd9

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="generator" content="pandoc"> <meta name="generator" content="pandoc">
<meta name="author" content="Will King (will@youainti.com)"> <meta name="author" content="Will King (presentation+git@youainti.com)">
<title>Introduction to Version Control Systems (GIT) for Economists</title> <title>Introduction to Version Control Systems (GIT) for Economists</title>
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
@ -135,7 +135,7 @@
<section id="title-slide"> <section id="title-slide">
<h1 class="title">Introduction to Version Control Systems (GIT) for <h1 class="title">Introduction to Version Control Systems (GIT) for
Economists</h1> Economists</h1>
<p class="author">Will King (will@youainti.com)</p> <p class="author">Will King (presentation+git@youainti.com)</p>
</section> </section>
<section> <section>
@ -259,11 +259,11 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="
<li><code>cd</code>: Change Directory.</li> <li><code>cd</code>: Change Directory.</li>
<li><code>nano</code>: The text editor we will be using.</li> <li><code>nano</code>: The text editor we will be using.</li>
</ul> </ul>
<details> <aside class="notes">
<summary>Instructors Notes</summary> <p>Get everyone to open bash at their home location. pwd, then talk
Get everyone to open bash at their home location. pwd, then talk about slashes etc. about slashes etc. Talk about spaces and quoting and escaping. Show a
Talk about spaces and quoting and escaping. Show a variety of paths. variety of paths.</p>
</details> </aside>
</section> </section>
<section id="bash-activity" class="slide level2"> <section id="bash-activity" class="slide level2">
<h2>Bash Activity</h2> <h2>Bash Activity</h2>
@ -275,19 +275,15 @@ zip file Ive provided.</p>
<li>Start exploring the directories using the command line.</li> <li>Start exploring the directories using the command line.</li>
</ol> </ol>
<p>How is this similar to using your file browser?</p> <p>How is this similar to using your file browser?</p>
<details> <p>Try typing <code>nano [filename]</code> to open one of the text
<summary>Viewing files</summary> files</p>
To view files from the command line, you have a couple of options: <aside class="notes">
Vi/Vim, Emacs, Nano, etc. <p>There are a couple of files with useful information.</p>
The most basic one you can try is Nano. <p>Please go through them with the students as you explore the
Try typing nano [filename]. filetree.</p>
</details> <p>It might be helpful to go through the directory outside of the
<details> command line too.</p>
<summary>Instructors Notes</summary> </aside>
There are a couple of files with useful information.
Please go through them with the students as you explore the filetree.
It might be helpful to go through the directory outside of the command line too.
</details>
</section> </section>
<section id="getting-help-on-the-command-line" class="slide level2"> <section id="getting-help-on-the-command-line" class="slide level2">
<h2>Getting help on the command line</h2> <h2>Getting help on the command line</h2>
@ -306,10 +302,14 @@ get help:</p>
class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ls</span> <span class="at">--help</span></span> class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ls</span> <span class="at">--help</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="fu">man</span> ls</span> <span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="fu">man</span> ls</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">info</span> ls</span></code></pre></div> <span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">info</span> ls</span></code></pre></div>
<details> <aside class="notes">
<summary>Instructors Notes</summary> <p>Examine some of the CLI options for the command presented earlier.
Examine some of the CLI options for the command presented earlier. Maybe:</p>
</details> <ul>
<li><code>ls -l</code></li>
<li><code>ls -a</code></li>
</ul>
</aside>
</section></section> </section></section>
<section> <section>
<section id="git-basics---recording-file-changes" <section id="git-basics---recording-file-changes"
@ -391,7 +391,7 @@ doing and why.</li>
<h2>Lets Practice</h2> <h2>Lets Practice</h2>
<p>Lets make personal wikis to keep track of what we are doing.</p> <p>Lets make personal wikis to keep track of what we are doing.</p>
<ol type="1"> <ol type="1">
<li>navigate to the base directory that I gave you.</li> <li>navigate to the <code>git_intro_download/</code> directory.</li>
<li>initialize a git repo using <code>git init wiki</code></li> <li>initialize a git repo using <code>git init wiki</code></li>
<li>change directory to wiki</li> <li>change directory to wiki</li>
<li><code>nano basic_git_workflow.txt</code></li> <li><code>nano basic_git_workflow.txt</code></li>
@ -608,7 +608,7 @@ edits of <code>e.txt</code></li>
<p>This is called a conflict, where the same file has had different <p>This is called a conflict, where the same file has had different
changes happen in different branches.</p> changes happen in different branches.</p>
<p>To handle this, Git asks you to resolve it, choosing what should be <p>To handle this, Git asks you to resolve it, choosing what should be
kept or removed. Resolving a conflict is called a merge.</p> kept or removed. Resolving a conflict is part of merging branches.</p>
<p>Merging is the main skill we want to develop.</p> <p>Merging is the main skill we want to develop.</p>
</section> </section>
<section id="rewriting-history---the-dag-can-be-modified-kind-of" <section id="rewriting-history---the-dag-can-be-modified-kind-of"
@ -694,10 +694,15 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb17-1"><a href=
<div class="sourceCode" id="cb18"><pre <div class="sourceCode" id="cb18"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch spellcheck</span> class="sourceCode bash"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch spellcheck</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;hello world&quot;</span> <span class="op">&gt;</span> n.txt</span> <span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;hello world&quot;</span> <span class="op">&gt;</span> n.txt</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch main</span> <span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> add n.txt</span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge spellcheck</span> <span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> commit <span class="at">-m</span> <span class="st">&quot;said hello to terra&quot;</span></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> log <span class="at">--graph</span> <span class="at">--oneline</span></span></code></pre></div> <span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch main</span>
<p>This is called a fast-forward merge.</p> <span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a><span class="fu">ls</span> <span class="co">#note how n is missing</span></span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> log <span class="at">--oneline</span></span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge spellcheck</span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> log <span class="at">--oneline</span></span></code></pre></div>
<p>This is called a fast-forward merge and occurrs when branches dont
have conflicts.</p>
</section> </section>
<section id="creating-conflicts" class="slide level2"> <section id="creating-conflicts" class="slide level2">
<h2>Creating Conflicts</h2> <h2>Creating Conflicts</h2>
@ -709,25 +714,23 @@ same file(s).</p>
<p>Lets create a conflict in our wiki repo.</p> <p>Lets create a conflict in our wiki repo.</p>
<div class="sourceCode" id="cb19"><pre <div class="sourceCode" id="cb19"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> checkout spellcheck</span> class="sourceCode bash"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> checkout spellcheck</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">nemo</span> favorites.txt <span class="co">#Talk about your favorite color</span></span> <span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="fu">nano</span> favorites.txt <span class="co">#Talk about your favorite color</span></span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> add favorites.txt</span> <span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> add favorites.txt</span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> commit <span class="at">-m</span> <span class="st">&quot;write an actual description&quot;</span></span> <span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> commit <span class="at">-m</span> <span class="st">&quot;write an actual description&quot;</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch main</span> <span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch main</span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a><span class="ex">nemo</span> favorites.txt <span class="co">#Talk about your favorite food&quot;</span></span> <span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a><span class="fu">nano</span> favorites.txt <span class="co">#Talk about your favorite food&quot;</span></span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> add favorites.txt</span> <span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> add favorites.txt</span>
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> commit <span class="at">-m</span> <span class="st">&quot;write an actual description&quot;</span></span> <span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> commit <span class="at">-m</span> <span class="st">&quot;write an actual description&quot;</span></span>
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> log <span class="at">--graph</span> <span class="at">--oneline</span></span> <span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> log <span class="at">--oneline</span></span>
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge spellcheck</span></code></pre></div> <span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge spellcheck</span></code></pre></div>
</section> </section>
<section id="three-way-merges" class="slide level2"> <section id="three-way-merges" class="slide level2">
<h2>Three Way Merges</h2> <h2>Three Way Merges</h2>
<p>In this case we have a warning message: <code>TODO</code></p> <p>In this case we have a warning message:
<p>We have two conflicting changes to the <code>favorites.txt</code> <code>CONFLICT (add/add): Merge conflict in favorites.txt</code></p>
file.</p>
<p>We need to choose between them.</p>
<div class="sourceCode" id="cb20"><pre <div class="sourceCode" id="cb20"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> status</span> class="sourceCode bash"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> status</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ex">nemo</span> favorites.txt</span></code></pre></div> <span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="fu">nano</span> favorites.txt</span></code></pre></div>
<p>Note the symbols “&lt;&lt;&lt;&lt;&lt;” “======” <p>Note the symbols “&lt;&lt;&lt;&lt;&lt;” “======”
&gt;&gt;&gt;&gt;&gt;”. These tell us what the differences are between &gt;&gt;&gt;&gt;&gt;”. These tell us what the differences are between
the commits</p> the commits</p>
@ -737,6 +740,8 @@ the commits</p>
<li>stage the changes.</li> <li>stage the changes.</li>
<li>commit the merged files.</li> <li>commit the merged files.</li>
</ul> </ul>
<div class="sourceCode" id="cb21"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> log <span class="at">--graph</span> <span class="at">--oneline</span></span></code></pre></div>
</section> </section>
<section id="practice-5-min" class="slide level2"> <section id="practice-5-min" class="slide level2">
<h2>Practice (5 min)</h2> <h2>Practice (5 min)</h2>
@ -748,13 +753,16 @@ color. Notice that spellcheck didnt get the changes from main.</li>
<li>merge spellcheck into main (checkout main then <li>merge spellcheck into main (checkout main then
<code>git merge spellcheck</code>)</li> <code>git merge spellcheck</code>)</li>
<li>Resolve the merge.</li> <li>Resolve the merge.</li>
<li>merge main into spellcheck at some point.</li>
</ul> </ul>
<p>Why would normal practice be to merge your release branch into your
development branch, then merge back?</p>
</section> </section>
<section id="introducing-a-normal-workflow" class="slide level2"> <section id="introducing-a-normal-workflow" class="slide level2">
<h2>Introducing a normal workflow</h2> <h2>Introducing a normal workflow</h2>
<p>Usually, you have branches that represent “states” and branches that <p>Usually, you have branches that represent releases and branches that
represent areas you are working on.</p> represent areas you are working on.</p>
<p>Consider the following branches</p> <p>Consider the following branches.</p>
<ul> <ul>
<li><code>main</code>: This is the branch that you are using to present <li><code>main</code>: This is the branch that you are using to present
work that you consider somewhat complete, i.e. when you have a first work that you consider somewhat complete, i.e. when you have a first
@ -777,7 +785,8 @@ pulling the most recent data to analyze.</li>
<li class="fragment">Create <code>data_processing</code> branch</li> <li class="fragment">Create <code>data_processing</code> branch</li>
<li class="fragment">Get <code>data_processing</code> to a working state <li class="fragment">Get <code>data_processing</code> to a working state
(committing along the way).</li> (committing along the way).</li>
<li class="fragment">merge <code>data_processing</code> into main.</li> <li class="fragment">merge main into data processing, fix conflicts,
then merge<code>data_processing</code> into main.</li>
<li class="fragment">create a branch <code>regression_analysis</code> <li class="fragment">create a branch <code>regression_analysis</code>
from main.</li> from main.</li>
<li class="fragment">start writing your analysis, committing along the <li class="fragment">start writing your analysis, committing along the
@ -810,13 +819,13 @@ writing your report.</li>
<p>Sometimes when you have a bunch of small rough changes, you might <p>Sometimes when you have a bunch of small rough changes, you might
want to turn them into a single (nice looking) commit.</p> want to turn them into a single (nice looking) commit.</p>
<p>This is called squashing</p> <p>This is called squashing</p>
<div class="sourceCode" id="cb21"><pre <div class="sourceCode" id="cb22"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge <span class="at">--squash</span> [branch name]</span></code></pre></div> class="sourceCode bash"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge <span class="at">--squash</span> [branch name]</span></code></pre></div>
<p>For example, if we had 3 commits in spellcheck, we could squash merge <p>For example, if we had 3 commits in spellcheck, we could squash merge
them into main by:</p> them into main by:</p>
<div class="sourceCode" id="cb22"><pre <div class="sourceCode" id="cb23"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch main</span> class="sourceCode bash"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch main</span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge <span class="at">--squash</span> spellcheck</span></code></pre></div> <span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge <span class="at">--squash</span> spellcheck</span></code></pre></div>
<p>This is one way to rewrite the DAG. It depends on the fact that <p>This is one way to rewrite the DAG. It depends on the fact that
branches are disposable. There is no need to keep a branch around after branches are disposable. There is no need to keep a branch around after
it is squashed.</p> it is squashed.</p>
@ -861,19 +870,19 @@ class="fragment"><code>git clone /path/to/onedrive/folder/with/repo</code></li>
</section> </section>
<section id="remote-workflow" class="slide level2"> <section id="remote-workflow" class="slide level2">
<h2>Remote workflow</h2> <h2>Remote workflow</h2>
<div class="sourceCode" id="cb23"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Begin by fetching chagnes</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> fetch remote/branch</span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Merge changes from remote branch into your current branch</span></span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge remote/branch</span>
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Work like normal</span></span>
<span id="cb23-7"><a href="#cb23-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb23-8"><a href="#cb23-8" aria-hidden="true" tabindex="-1"></a><span class="co"># Give your updates back</span></span>
<span id="cb23-9"><a href="#cb23-9" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> push remote/branch</span></code></pre></div>
<p>There is a command that combines the fetch and merge steps:</p>
<div class="sourceCode" id="cb24"><pre <div class="sourceCode" id="cb24"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> pull remote/branch</span></code></pre></div> class="sourceCode bash"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Begin by fetching chagnes</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> fetch remote/branch</span>
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a><span class="co"># Merge changes from remote branch into your current branch</span></span>
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> merge remote/branch</span>
<span id="cb24-5"><a href="#cb24-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb24-6"><a href="#cb24-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Work like normal</span></span>
<span id="cb24-7"><a href="#cb24-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb24-8"><a href="#cb24-8" aria-hidden="true" tabindex="-1"></a><span class="co"># Give your updates back</span></span>
<span id="cb24-9"><a href="#cb24-9" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> push remote/branch</span></code></pre></div>
<p>There is a command that combines the fetch and merge steps:</p>
<div class="sourceCode" id="cb25"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> pull remote/branch</span></code></pre></div>
</section> </section>
<section id="exercise" class="slide level2"> <section id="exercise" class="slide level2">
<h2>Exercise</h2> <h2>Exercise</h2>
@ -915,8 +924,11 @@ development.</li>
<section id="demo-git-forge" class="slide level2"> <section id="demo-git-forge" class="slide level2">
<h2>Demo Git Forge</h2> <h2>Demo Git Forge</h2>
<p>I have a git forge that we are going to practice using</p> <p>I have a git forge that we are going to practice using</p>
<p>We are going to - add it as a remote - continue the experiment using <p>We are going to</p>
the remote.</p> <ul>
<li>add it as a remote</li>
<li>continue the experiment using the remote.</li>
</ul>
</section> </section>
<section id="cloning-non-local-remote" class="slide level2"> <section id="cloning-non-local-remote" class="slide level2">
<h2>Cloning non-local remote</h2> <h2>Cloning non-local remote</h2>
@ -929,74 +941,100 @@ the remote.</p>
<li>Merging to Main.</li> <li>Merging to Main.</li>
</ul> </ul>
<blockquote> <blockquote>
<p>[!NOTE] I will be removing your access to this git remote sometime <p>NOTE!!! I will be removing your access to this git remote sometime
soon. You will still have a local copy of the wiki though!</p> after the lab is over. You will still have a local copy of the wiki
though!</p>
</blockquote> </blockquote>
</section></section> </section></section>
<section> <section>
<section id="how-have-i-used-git-in-my-work" <section id="final-thoughts" class="title-slide slide level1">
class="title-slide slide level1"> <h1>Final Thoughts</h1>
<h1>How have I used Git in my work?</h1>
</section> </section>
<section id="tracking-code-and-data" class="slide level2"> <section id="how-have-i-used-git-in-my-work" class="slide level2">
<h2>Tracking Code and Data</h2> <h2>How have I used Git in my work?</h2>
<ul> <ul>
<li>I have used git to track my code for both data processing and data <li><p>I have used git to track my code for both data processing and
analysis</li> data analysis</p></li>
<li>If I were taking a class on econometrics where we have to code up <li><p>If I were taking a class on econometrics where we have to code up
some analyses, I might keep track of it in Git. A folder for each some analyses, I might keep track of it in Git. A folder for each
homework, tagging it right before submitting it. I would only use one homework, tagging it right before submitting it. I would only use one
branch probably.</li> branch probably.</p></li>
<li>I have used git to coordinate work for an econometrics group <li><p>I have used git to coordinate work for an econometrics group
project.</li> project.</p></li>
</ul> <li><p>I use it to recover an analysis that I deleted by
</section> accident.</p></li>
<section id="latex-development" class="slide level2"> <li><p>I am currently working on my disseration in LaTeX.</p></li>
<h2>Latex Development</h2> <li><p>I use git to be able to revert mistakes and sync work across
<ul> multiple computers.</p></li>
<li>I am currently working on my disseration in LaTeX.</li>
<li>I use git to be able to revert mistakes and sync work across
multiple computers.</li>
</ul> </ul>
</section></section>
<section>
<section id="final-thoughts" class="title-slide slide level1">
<h1>Final Thoughts</h1>
</section> </section>
<section id="what-should-you-continue-learning" class="slide level2"> <section id="what-should-you-continue-learning" class="slide level2">
<h2>What should you continue learning?</h2> <h2>What should you continue learning?</h2>
<ul> <ul>
<li>.gitignore files - Sometimes you dont want to stage a whole class <li><strong>.gitignore files</strong> - Sometimes you dont want to
of files. A <code>.gitignore</code> file tell git to not to stage them. stage a whole class of files. A <code>.gitignore</code> file tell git to
For example, if you are doing an analysis in python, you might get a not to stage them. For example, if you are doing an analysis in python,
<code>__pycache__/</code> directory. If you put a line that says you might get a <code>__pycache__/</code> directory. If you put a line
<code>*/__pycache__/</code> in your <code>.gitignore</code>, it will not that says <code>*/__pycache__/</code> in your <code>.gitignore</code>,
be suggested that you stage anything in that directory.</li> it will not be suggested that you stage anything in that directory.</li>
<li>Git LFS - Saving large files that are not text can be difficult, <li><strong>Git LFS</strong> - Saving large files that are not text can
such as when you are saving <code>.pdf</code>, <code>.jpg</code>, be difficult, such as when you are saving <code>.pdf</code>,
<code>.png</code>,<code>.xlsx</code>, <code>.docx</code>, or <code>.jpg</code>, <code>.png</code>,<code>.xlsx</code>,
<code>.zip</code> files. Any change will cause the whole thing to be <code>.docx</code>, or <code>.zip</code> files. Any change will cause
resaved, and this can quickly add up to lots of storage being used. Git the whole thing to be resaved, and this can quickly add up to lots of
LFS does a couple of things to reduce how much storage will be storage being used. Git LFS does a couple of things to reduce how much
used.</li> storage will be used.</li>
<li>Branching Strategies - Knowing how to setup and use branches <li><strong>Branching Strategies</strong> - Knowing how to setup and use
properly is a powerful thing. There are tons of blogs with information branches properly is a powerful thing. There are tons of blogs with
from different companies explaining how they are doing it.</li> information from different companies explaining how they are doing
<li>Merging and Rebasing tools - There is so much to do here.</li> it.</li>
<li><strong>Advanced Merging and Rebasing</strong> - There is so much to
do here.</li>
</ul> </ul>
</section> </section>
<section id="most-of-all" class="slide level2"> <section id="most-of-all" class="slide level2">
<h2>Most of All</h2> <h2>Most of All</h2>
<h3 id="practice">Practice!</h3> <h3 id="practice">Practice!</h3>
</section> </section>
<section id="conclusion" class="slide level2">
<h2>Conclusion</h2>
<figure>
<img data-src="https://imgs.xkcd.com/comics/git.png"
alt="If that doesnt fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of Its really pretty simple, just think of branches as… and eventually youll learn the commands that will fix everything." />
<figcaption aria-hidden="true">If that doesnt fix it, git.txt contains
the phone number of a friend of mine who understands git. Just wait
through a few minutes of Its really pretty simple, just think of
branches as… and eventually youll learn the commands that will fix
everything.</figcaption>
</figure>
<p>Im sorry, you just became the local git expert…</p>
</section>
<section id="seriously-though" class="slide level2">
<h2>Seriously though</h2>
<ul>
<li>Git is a useful tool to keep track of software versions and
coordinate work.</li>
<li>Most of the time you can get away with just memorizing some basic
commands and workflow</li>
<li>When things are hard, remember
<ul>
<li>The basic model of how it works. Try to figure out what went
wrong.</li>
<li>DuckDuckGo search is your friend. Google might be as well.</li>
<li>ChatGPT/Claude.ai are pretty good at explaining errors, commands,
etc.</li>
</ul></li>
<li>Dont commit anything that needs to remain secret. It is rather hard
to delete something from a Git repo.</li>
</ul>
</section>
<section id="feedback" class="slide level2"> <section id="feedback" class="slide level2">
<h2>Feedback</h2> <h2>Feedback</h2>
<ul> <ul>
<li>What questions do you have?</li> <li>What questions do you have?</li>
<li>What would you like to keep practicing?</li> <li>What would you like to keep practicing?</li>
<li>How could I improve?</li> <li>How could I improve this presentation?</li>
</ul> </ul>
</section></section> </section></section>
</div> </div>

@ -1,6 +1,6 @@
--- ---
title: Introduction to Version Control Systems (GIT) for Economists title: Introduction to Version Control Systems (GIT) for Economists
author: Will King (will@youainti.com) author: Will King (presentation+git@youainti.com)
theme: league theme: league
--- ---
@ -75,13 +75,10 @@ command "this has one argument"
- `cd`: Change Directory. - `cd`: Change Directory.
- `nano`: The text editor we will be using. - `nano`: The text editor we will be using.
```{=html} ::: notes
<details>
<summary>Instructors Notes</summary>
Get everyone to open bash at their home location. pwd, then talk about slashes etc. Get everyone to open bash at their home location. pwd, then talk about slashes etc.
Talk about spaces and quoting and escaping. Show a variety of paths. Talk about spaces and quoting and escaping. Show a variety of paths.
</details> :::
```
## Bash Activity ## Bash Activity
Prep: [Download](https://www.youainti.com) and extract the zip file I've provided. Prep: [Download](https://www.youainti.com) and extract the zip file I've provided.
@ -93,23 +90,15 @@ Prep: [Download](https://www.youainti.com) and extract the zip file I've provide
How is this similar to using your file browser? How is this similar to using your file browser?
```{=html} Try typing `nano [filename]` to open one of the text files
<details>
<summary>Viewing files</summary> ::: notes
To view files from the command line, you have a couple of options:
Vi/Vim, Emacs, Nano, etc.
The most basic one you can try is Nano.
Try typing nano [filename].
</details>
```
```{=html}
<details>
<summary>Instructors Notes</summary>
There are a couple of files with useful information. There are a couple of files with useful information.
Please go through them with the students as you explore the filetree. Please go through them with the students as you explore the filetree.
It might be helpful to go through the directory outside of the command line too. It might be helpful to go through the directory outside of the command line too.
</details> :::
```
## Getting help on the command line ## Getting help on the command line
@ -127,12 +116,14 @@ man ls
info ls info ls
``` ```
```{=html} ::: notes
<details>
<summary>Instructors Notes</summary>
Examine some of the CLI options for the command presented earlier. Examine some of the CLI options for the command presented earlier.
</details> Maybe:
```
- `ls -l`
- `ls -a`
:::
@ -216,7 +207,7 @@ git commit
Let's make personal wiki's to keep track of what we are doing. Let's make personal wiki's to keep track of what we are doing.
1. navigate to the base directory that I gave you. 1. navigate to the `git_intro_download/` directory.
2. initialize a git repo using `git init wiki` 2. initialize a git repo using `git init wiki`
3. change directory to wiki 3. change directory to wiki
4. `nano basic_git_workflow.txt` 4. `nano basic_git_workflow.txt`
@ -408,7 +399,7 @@ changes happen in different branches.
To handle this, Git asks you to resolve it, choosing what should be kept To handle this, Git asks you to resolve it, choosing what should be kept
or removed. or removed.
Resolving a conflict is called a merge. Resolving a conflict is part of merging branches.
Merging is the main skill we want to develop. Merging is the main skill we want to develop.
@ -503,12 +494,16 @@ Ok, let's do the following:
```bash ```bash
git switch spellcheck git switch spellcheck
echo "hello world" > n.txt echo "hello world" > n.txt
git add n.txt
git commit -m "said hello to terra"
git switch main git switch main
ls #note how n is missing
git log --oneline
git merge spellcheck git merge spellcheck
git log --graph --oneline git log --oneline
``` ```
This is called a fast-forward merge. This is called a fast-forward merge and occurrs when branches don't have conflicts.
## Creating Conflicts ## Creating Conflicts
@ -520,28 +515,24 @@ Let's create a conflict in our wiki repo.
```bash ```bash
git checkout spellcheck git checkout spellcheck
nemo favorites.txt #Talk about your favorite color nano favorites.txt #Talk about your favorite color
git add favorites.txt git add favorites.txt
git commit -m "write an actual description" git commit -m "write an actual description"
git switch main git switch main
nemo favorites.txt #Talk about your favorite food" nano favorites.txt #Talk about your favorite food"
git add favorites.txt git add favorites.txt
git commit -m "write an actual description" git commit -m "write an actual description"
git log --graph --oneline git log --oneline
git merge spellcheck git merge spellcheck
``` ```
## Three Way Merges ## Three Way Merges
In this case we have a warning message: `TODO` In this case we have a warning message: `CONFLICT (add/add): Merge conflict in favorites.txt`
We have two conflicting changes to the `favorites.txt` file.
We need to choose between them.
```bash ```bash
git status git status
nemo favorites.txt nano favorites.txt
``` ```
Note the symbols "<<<<<" "======" ">>>>>". Note the symbols "<<<<<" "======" ">>>>>".
@ -553,6 +544,9 @@ To resolve the commit:
- stage the changes. - stage the changes.
- commit the merged files. - commit the merged files.
```bash
git log --graph --oneline
```
## Practice (5 min) ## Practice (5 min)
@ -561,13 +555,17 @@ To resolve the commit:
Notice that spellcheck didn't get the changes from main. Notice that spellcheck didn't get the changes from main.
- merge spellcheck into main (checkout main then `git merge spellcheck`) - merge spellcheck into main (checkout main then `git merge spellcheck`)
- Resolve the merge. - Resolve the merge.
- merge main into spellcheck at some point.
Why would normal practice be to merge your release branch into your
development branch, then merge back?
## Introducing a normal workflow ## Introducing a normal workflow
Usually, you have branches that represent "states" and branches that represent Usually, you have branches that represent releases and branches that represent
areas you are working on. areas you are working on.
Consider the following branches Consider the following branches.
- `main`: This is the branch that you are using to present work that you - `main`: This is the branch that you are using to present work that you
consider somewhat complete, i.e. when you have a first draft of your data consider somewhat complete, i.e. when you have a first draft of your data
@ -588,7 +586,7 @@ What this might look like.
>2. write things such as README in main. >2. write things such as README in main.
>3. Create `data_processing` branch >3. Create `data_processing` branch
>4. Get `data_processing` to a working state (committing along the way). >4. Get `data_processing` to a working state (committing along the way).
>5. merge `data_processing` into main. >5. merge main into data processing, fix conflicts, then merge`data_processing` into main.
>6. create a branch `regression_analysis` from main. >6. create a branch `regression_analysis` from main.
>7. start writing your analysis, committing along the way. >7. start writing your analysis, committing along the way.
>8. Notice that the data is incorrect. >8. Notice that the data is incorrect.
@ -715,6 +713,7 @@ A Git Forge provides
I have a git forge that we are going to practice using I have a git forge that we are going to practice using
We are going to We are going to
- add it as a remote - add it as a remote
- continue the experiment using the remote. - continue the experiment using the remote.
@ -727,12 +726,15 @@ We are going to
- Pushing branches from CLI - Pushing branches from CLI
- Merging to Main. - Merging to Main.
> [!NOTE] > NOTE!!!
> I will be removing your access to this git remote sometime soon. You will still have a local copy of the wiki though! I will be removing your access to this git remote sometime after the lab is over.
You will still have a local copy of the wiki though!
# How have I used Git in my work?
## Tracking Code and Data
# Final Thoughts
## How have I used Git in my work?
- I have used git to track my code for both data processing and data analysis - I have used git to track my code for both data processing and data analysis
- If I were taking a class on econometrics where we have to code up some - If I were taking a class on econometrics where we have to code up some
@ -740,40 +742,53 @@ analyses, I might keep track of it in Git.
A folder for each homework, tagging it right before submitting it. A folder for each homework, tagging it right before submitting it.
I would only use one branch probably. I would only use one branch probably.
- I have used git to coordinate work for an econometrics group project. - I have used git to coordinate work for an econometrics group project.
- I use it to recover an analysis that I deleted by accident.
## Latex Development
- I am currently working on my disseration in LaTeX. - I am currently working on my disseration in LaTeX.
- I use git to be able to revert mistakes and sync work across multiple computers. - I use git to be able to revert mistakes and sync work across multiple computers.
# Final Thoughts
## What should you continue learning? ## What should you continue learning?
- .gitignore files - Sometimes you don't want to stage a whole class of files. - **.gitignore files** - Sometimes you don't want to stage a whole class of files.
A `.gitignore` file tell git to not to stage them. A `.gitignore` file tell git to not to stage them.
For example, if you are doing an analysis in python, you might get a For example, if you are doing an analysis in python, you might get a
`__pycache__/` directory. `__pycache__/` directory.
If you put a line that says `*/__pycache__/` in your `.gitignore`, it will not If you put a line that says `*/__pycache__/` in your `.gitignore`, it will not
be suggested that you stage anything in that directory. be suggested that you stage anything in that directory.
- Git LFS - Saving large files that are not text can be difficult, such as - **Git LFS** - Saving large files that are not text can be difficult, such as
when you are saving `.pdf`, `.jpg`, `.png`,`.xlsx`, `.docx`, or `.zip` files. when you are saving `.pdf`, `.jpg`, `.png`,`.xlsx`, `.docx`, or `.zip` files.
Any change will cause the whole thing to be resaved, and this can quickly add Any change will cause the whole thing to be resaved, and this can quickly add
up to lots of storage being used. up to lots of storage being used.
Git LFS does a couple of things to reduce how much storage will be used. Git LFS does a couple of things to reduce how much storage will be used.
- Branching Strategies - Knowing how to setup and use branches properly is a - **Branching Strategies** - Knowing how to setup and use branches properly is a
powerful thing. powerful thing.
There are tons of blogs with information from different companies explaining There are tons of blogs with information from different companies explaining
how they are doing it. how they are doing it.
- Merging and Rebasing tools - There is so much to do here. - **Advanced Merging and Rebasing** - There is so much to do here.
## Most of All ## Most of All
### Practice! ### Practice!
## Conclusion
![If that doesn't fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of 'It's really pretty simple, just think of branches as...' and eventually you'll learn the commands that will fix everything.](https://imgs.xkcd.com/comics/git.png)
I'm sorry, you just became the local git expert...
## Seriously though
- Git is a useful tool to keep track of software versions and coordinate work.
- Most of the time you can get away with just memorizing some basic commands and workflow
- When things are hard, remember
- The basic model of how it works. Try to figure out what went wrong.
- DuckDuckGo search is your friend. Google might be as well.
- ChatGPT/Claude.ai are pretty good at explaining errors, commands, etc.
- Don't commit anything that needs to remain secret. It is rather hard to delete something from a Git repo.
## Feedback ## Feedback
- What questions do you have? - What questions do you have?
- What would you like to keep practicing? - What would you like to keep practicing?
- How could I improve? - How could I improve this presentation?

Loading…
Cancel
Save