<spanid="cb19-2"><ahref="#cb19-2"aria-hidden="true"tabindex="-1"></a><spanclass="ex">nemo</span> favorites.txt <spanclass="co">#Talk about your favorite color</span></span>
<spanid="cb19-2"><ahref="#cb19-2"aria-hidden="true"tabindex="-1"></a><spanclass="fu">nano</span> favorites.txt <spanclass="co">#Talk about your favorite color</span></span>
<spanid="cb19-4"><ahref="#cb19-4"aria-hidden="true"tabindex="-1"></a><spanclass="fu">git</span> commit <spanclass="at">-m</span><spanclass="st">"write an actual description"</span></span>
<spanid="cb19-6"><ahref="#cb19-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">nemo</span> favorites.txt <spanclass="co">#Talk about your favorite food"</span></span>
<spanid="cb19-6"><ahref="#cb19-6"aria-hidden="true"tabindex="-1"></a><spanclass="fu">nano</span> favorites.txt <spanclass="co">#Talk about your favorite food"</span></span>
<spanid="cb19-8"><ahref="#cb19-8"aria-hidden="true"tabindex="-1"></a><spanclass="fu">git</span> commit <spanclass="at">-m</span><spanclass="st">"write an actual description"</span></span>
class="sourceCode bash"><codeclass="sourceCode bash"><spanid="cb23-1"><ahref="#cb23-1"aria-hidden="true"tabindex="-1"></a><spanclass="co"># Begin by fetching chagnes</span></span>
<spanid="cb23-3"><ahref="#cb23-3"aria-hidden="true"tabindex="-1"></a><spanclass="co"># Merge changes from remote branch into your current branch</span></span>
class="sourceCode bash"><codeclass="sourceCode bash"><spanid="cb24-1"><ahref="#cb24-1"aria-hidden="true"tabindex="-1"></a><spanclass="co"># Begin by fetching chagnes</span></span>
<spanid="cb24-3"><ahref="#cb24-3"aria-hidden="true"tabindex="-1"></a><spanclass="co"># Merge changes from remote branch into your current branch</span></span>
alt="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." />
<figcaptionaria-hidden="true">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.</figcaption>
</figure>
<p>I’m sorry, you just became the local git expert…</p>
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

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.