final version of presentation

main
will king 2 years ago
parent c78c9743a0
commit 5fd1467fd9

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<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>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
@ -135,7 +135,7 @@
<section id="title-slide">
<h1 class="title">Introduction to Version Control Systems (GIT) for
Economists</h1>
<p class="author">Will King (will@youainti.com)</p>
<p class="author">Will King (presentation+git@youainti.com)</p>
</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>nano</code>: The text editor we will be using.</li>
</ul>
<details>
<summary>Instructors Notes</summary>
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.
</details>
<aside class="notes">
<p>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.</p>
</aside>
</section>
<section id="bash-activity" class="slide level2">
<h2>Bash Activity</h2>
@ -275,19 +275,15 @@ zip file Ive provided.</p>
<li>Start exploring the directories using the command line.</li>
</ol>
<p>How is this similar to using your file browser?</p>
<details>
<summary>Viewing files</summary>
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>
<details>
<summary>Instructors Notes</summary>
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>
<p>Try typing <code>nano [filename]</code> to open one of the text
files</p>
<aside class="notes">
<p>There are a couple of files with useful information.</p>
<p>Please go through them with the students as you explore the
filetree.</p>
<p>It might be helpful to go through the directory outside of the
command line too.</p>
</aside>
</section>
<section id="getting-help-on-the-command-line" class="slide level2">
<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>
<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>
<details>
<summary>Instructors Notes</summary>
Examine some of the CLI options for the command presented earlier.
</details>
<aside class="notes">
<p>Examine some of the CLI options for the command presented earlier.
Maybe:</p>
<ul>
<li><code>ls -l</code></li>
<li><code>ls -a</code></li>
</ul>
</aside>
</section></section>
<section>
<section id="git-basics---recording-file-changes"
@ -391,7 +391,7 @@ doing and why.</li>
<h2>Lets Practice</h2>
<p>Lets make personal wikis to keep track of what we are doing.</p>
<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>change directory to wiki</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
changes happen in different branches.</p>
<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>
</section>
<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
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-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> switch main</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-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>
<p>This is called a fast-forward merge.</p>
<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> 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> switch main</span>
<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 id="creating-conflicts" class="slide level2">
<h2>Creating Conflicts</h2>
@ -709,25 +714,23 @@ same file(s).</p>
<p>Lets create a conflict in our wiki repo.</p>
<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>
<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-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-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-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>
</section>
<section id="three-way-merges" class="slide level2">
<h2>Three Way Merges</h2>
<p>In this case we have a warning message: <code>TODO</code></p>
<p>We have two conflicting changes to the <code>favorites.txt</code>
file.</p>
<p>We need to choose between them.</p>
<p>In this case we have a warning message:
<code>CONFLICT (add/add): Merge conflict in favorites.txt</code></p>
<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>
<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;” “======”
&gt;&gt;&gt;&gt;&gt;”. These tell us what the differences are between
the commits</p>
@ -737,6 +740,8 @@ the commits</p>
<li>stage the changes.</li>
<li>commit the merged files.</li>
</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 id="practice-5-min" class="slide level2">
<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
<code>git merge spellcheck</code>)</li>
<li>Resolve the merge.</li>
<li>merge main into spellcheck at some point.</li>
</ul>
<p>Why would normal practice be to merge your release branch into your
development branch, then merge back?</p>
</section>
<section id="introducing-a-normal-workflow" class="slide level2">
<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>
<p>Consider the following branches</p>
<p>Consider the following branches.</p>
<ul>
<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
@ -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">Get <code>data_processing</code> to a working state
(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>
from main.</li>
<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
want to turn them into a single (nice looking) commit.</p>
<p>This is called squashing</p>
<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> merge <span class="at">--squash</span> [branch name]</span></code></pre></div>
<div class="sourceCode" id="cb22"><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> 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
them into main by:</p>
<div class="sourceCode" id="cb22"><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>
<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>
<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="fu">git</span> switch main</span>
<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
branches are disposable. There is no need to keep a branch around after
it is squashed.</p>
@ -861,19 +870,19 @@ class="fragment"><code>git clone /path/to/onedrive/folder/with/repo</code></li>
</section>
<section id="remote-workflow" class="slide level2">
<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
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 id="exercise" class="slide level2">
<h2>Exercise</h2>
@ -915,8 +924,11 @@ development.</li>
<section id="demo-git-forge" class="slide level2">
<h2>Demo Git Forge</h2>
<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
the remote.</p>
<p>We are going to</p>
<ul>
<li>add it as a remote</li>
<li>continue the experiment using the remote.</li>
</ul>
</section>
<section id="cloning-non-local-remote" class="slide level2">
<h2>Cloning non-local remote</h2>
@ -929,74 +941,100 @@ the remote.</p>
<li>Merging to Main.</li>
</ul>
<blockquote>
<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>
<p>NOTE!!! 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!</p>
</blockquote>
</section></section>
<section>
<section id="how-have-i-used-git-in-my-work"
class="title-slide slide level1">
<h1>How have I used Git in my work?</h1>
<section id="final-thoughts" class="title-slide slide level1">
<h1>Final Thoughts</h1>
</section>
<section id="tracking-code-and-data" class="slide level2">
<h2>Tracking Code and Data</h2>
<section id="how-have-i-used-git-in-my-work" class="slide level2">
<h2>How have I used Git in my work?</h2>
<ul>
<li>I have used git to track my code for both data processing and data
analysis</li>
<li>If I were taking a class on econometrics where we have to code up
<li><p>I have used git to track my code for both data processing and
data analysis</p></li>
<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
homework, tagging it right before submitting it. I would only use one
branch probably.</li>
<li>I have used git to coordinate work for an econometrics group
project.</li>
</ul>
</section>
<section id="latex-development" class="slide level2">
<h2>Latex Development</h2>
<ul>
<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>
branch probably.</p></li>
<li><p>I have used git to coordinate work for an econometrics group
project.</p></li>
<li><p>I use it to recover an analysis that I deleted by
accident.</p></li>
<li><p>I am currently working on my disseration in LaTeX.</p></li>
<li><p>I use git to be able to revert mistakes and sync work across
multiple computers.</p></li>
</ul>
</section></section>
<section>
<section id="final-thoughts" class="title-slide slide level1">
<h1>Final Thoughts</h1>
</section>
<section id="what-should-you-continue-learning" class="slide level2">
<h2>What should you continue learning?</h2>
<ul>
<li>.gitignore files - Sometimes you dont want to stage a whole class
of files. A <code>.gitignore</code> file tell git to not to stage them.
For example, if you are doing an analysis in python, you might get a
<code>__pycache__/</code> directory. If you put a line that says
<code>*/__pycache__/</code> in your <code>.gitignore</code>, 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,
such as when you are saving <code>.pdf</code>, <code>.jpg</code>,
<code>.png</code>,<code>.xlsx</code>, <code>.docx</code>, or
<code>.zip</code> files. Any change will cause the whole thing to be
resaved, and this can quickly add up to lots of storage being used. Git
LFS does a couple of things to reduce how much storage will be
used.</li>
<li>Branching Strategies - Knowing how to setup and use branches
properly is a powerful thing. There are tons of blogs with information
from different companies explaining how they are doing it.</li>
<li>Merging and Rebasing tools - There is so much to do here.</li>
<li><strong>.gitignore files</strong> - Sometimes you dont want to
stage a whole class of files. A <code>.gitignore</code> file tell git to
not to stage them. For example, if you are doing an analysis in python,
you might get a <code>__pycache__/</code> directory. If you put a line
that says <code>*/__pycache__/</code> in your <code>.gitignore</code>,
it will not be suggested that you stage anything in that directory.</li>
<li><strong>Git LFS</strong> - Saving large files that are not text can
be difficult, such as when you are saving <code>.pdf</code>,
<code>.jpg</code>, <code>.png</code>,<code>.xlsx</code>,
<code>.docx</code>, or <code>.zip</code> files. Any change will cause
the whole thing to be resaved, and this can quickly add up to lots of
storage being used. Git LFS does a couple of things to reduce how much
storage will be used.</li>
<li><strong>Branching Strategies</strong> - Knowing how to setup and use
branches properly is a powerful thing. There are tons of blogs with
information from different companies explaining how they are doing
it.</li>
<li><strong>Advanced Merging and Rebasing</strong> - There is so much to
do here.</li>
</ul>
</section>
<section id="most-of-all" class="slide level2">
<h2>Most of All</h2>
<h3 id="practice">Practice!</h3>
</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">
<h2>Feedback</h2>
<ul>
<li>What questions do you have?</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>
</section></section>
</div>

@ -1,6 +1,6 @@
---
title: Introduction to Version Control Systems (GIT) for Economists
author: Will King (will@youainti.com)
author: Will King (presentation+git@youainti.com)
theme: league
---
@ -75,13 +75,10 @@ command "this has one argument"
- `cd`: Change Directory.
- `nano`: The text editor we will be using.
```{=html}
<details>
<summary>Instructors Notes</summary>
::: notes
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.
</details>
```
:::
## Bash Activity
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?
```{=html}
<details>
<summary>Viewing files</summary>
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>
Try typing `nano [filename]` to open one of the text files
::: notes
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>
```
:::
## Getting help on the command line
@ -127,12 +116,14 @@ man ls
info ls
```
```{=html}
<details>
<summary>Instructors Notes</summary>
::: notes
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.
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`
3. change directory to wiki
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
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.
@ -503,12 +494,16 @@ Ok, let's do the following:
```bash
git switch spellcheck
echo "hello world" > n.txt
git add n.txt
git commit -m "said hello to terra"
git switch main
ls #note how n is missing
git log --oneline
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
@ -520,28 +515,24 @@ Let's create a conflict in our wiki repo.
```bash
git checkout spellcheck
nemo favorites.txt #Talk about your favorite color
nano favorites.txt #Talk about your favorite color
git add favorites.txt
git commit -m "write an actual description"
git switch main
nemo favorites.txt #Talk about your favorite food"
nano favorites.txt #Talk about your favorite food"
git add favorites.txt
git commit -m "write an actual description"
git log --graph --oneline
git log --oneline
git merge spellcheck
```
## Three Way Merges
In this case we have a warning message: `TODO`
We have two conflicting changes to the `favorites.txt` file.
We need to choose between them.
In this case we have a warning message: `CONFLICT (add/add): Merge conflict in favorites.txt`
```bash
git status
nemo favorites.txt
nano favorites.txt
```
Note the symbols "<<<<<" "======" ">>>>>".
@ -553,6 +544,9 @@ To resolve the commit:
- stage the changes.
- commit the merged files.
```bash
git log --graph --oneline
```
## Practice (5 min)
@ -561,13 +555,17 @@ To resolve the commit:
Notice that spellcheck didn't get the changes from main.
- merge spellcheck into main (checkout main then `git merge spellcheck`)
- 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
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.
Consider the following branches
Consider the following branches.
- `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
@ -588,7 +586,7 @@ What this might look like.
>2. write things such as README in main.
>3. Create `data_processing` branch
>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.
>7. start writing your analysis, committing along the way.
>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
We are going to
- add it as a remote
- continue the experiment using the remote.
@ -727,12 +726,15 @@ We are going to
- Pushing branches from CLI
- Merging to Main.
> [!NOTE]
> I will be removing your access to this git remote sometime soon. You will still have a local copy of the wiki though!
> NOTE!!!
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
- 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.
I would only use one branch probably.
- I have used git to coordinate work for an econometrics group project.
## Latex Development
- I use it to recover an analysis that I deleted by accident.
- I am currently working on my disseration in LaTeX.
- I use git to be able to revert mistakes and sync work across multiple computers.
# Final Thoughts
## 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.
For example, if you are doing an analysis in python, you might get a
`__pycache__/` directory.
If you put a line that says `*/__pycache__/` in your `.gitignore`, it will not
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.
Any change will cause the whole thing to be resaved, and this can quickly add
up to lots of storage being 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.
There are tons of blogs with information from different companies explaining
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
### 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
- What questions do you have?
- What would you like to keep practicing?
- How could I improve?
- How could I improve this presentation?

Loading…
Cancel
Save