@ -126,6 +126,39 @@
p {
p {
text-align: left;
text-align: left;
}
}
.license-footer {
opacity: 0.6;
transition: opacity 0.3s ease;
}
.license-footer:hover {
opacity: 1;
}
.license-icons {
cursor: pointer;
}
.license-tooltip {
display: none;
position: absolute;
background-color: rgba(0, 0, 0, 0.8);
color: #fff;
padding: 5px 10px;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
top: 100%;
right: 0;
margin-top: 5px;
}
.license-footer:hover .license-tooltip {
display: block;
}
< / style >
< / style >
< / head >
< / head >
< body >
< body >
@ -138,6 +171,8 @@ Economists</h1>
< p class = "author" > Will King (presentation+git@youainti.com)< / p >
< p class = "author" > Will King (presentation+git@youainti.com)< / p >
< / section >
< / section >
< div class = "reveal" >
< div class = "slides" >
< section >
< section >
< section id = "what-is-git" class = "title-slide slide level1" >
< section id = "what-is-git" class = "title-slide slide level1" >
< h1 > What Is Git?< / h1 >
< h1 > What Is Git?< / h1 >
@ -153,7 +188,8 @@ alt="What is Git? Explanation at ExplainXKCD" />
at ExplainXKCD< / a > < / figcaption >
at ExplainXKCD< / a > < / figcaption >
< / figure >
< / figure >
< / section >
< / section >
< section id = "what-problems-are-we-trying-to-solve" class = "slide level2" >
< section id = "what-problems-are-we-trying-to-solve"
class="slide level2">
< h2 > What problems are we trying to solve?< / h2 >
< h2 > What problems are we trying to solve?< / h2 >
< ul >
< ul >
< li > How can we keep track of our work?< / li >
< li > How can we keep track of our work?< / li >
@ -261,14 +297,14 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="
< / ul >
< / ul >
< aside class = "notes" >
< aside class = "notes" >
< p > Get everyone to open bash at their home location. pwd, then talk
< 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
about slashes etc. Talk about spaces and quoting and escaping. Show
variety of paths.< / p >
a variety of paths.< / p >
< / aside >
< / 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 >
< p > Prep: < a href = "https://www.youainti.com" > Download< / a > and extract the
< p > Prep: < a href = "https://www.youainti.com" > Download< / a > and extract
zip file I’ ve provided.< / p >
the zip file I’ ve provided.< / p >
< ol type = "1" >
< ol type = "1" >
< li > Open bash/gitbash in the extracted directory.< / li >
< li > Open bash/gitbash in the extracted directory.< / li >
< li > Figure out what directory you are in.< / li >
< li > Figure out what directory you are in.< / li >
@ -287,8 +323,8 @@ command line too.</p>
< / 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 >
< p > When you run into issues on the command line, you need to know how to
< p > When you run into issues on the command line, you need to know
get help:< / p >
how to get help:< / p >
< ul >
< ul >
< li > internet searches (google, stackoverflow, etc)< / li >
< li > internet searches (google, stackoverflow, etc)< / li >
< li > local resources
< li > local resources
@ -303,8 +339,8 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="
< 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 >
< aside class = "notes" >
< aside class = "notes" >
< p > Examine some of the CLI options for the command presented earlier.
< p > Examine some of the CLI options for the command presented
Maybe:< / p >
earlier. Maybe:< / p >
< ul >
< ul >
< li > < code > ls -l< / code > < / li >
< li > < code > ls -l< / code > < / li >
< li > < code > ls -a< / code > < / li >
< li > < code > ls -a< / code > < / li >
@ -320,7 +356,8 @@ class="title-slide slide level1">
< section id = "concepts" class = "slide level2" >
< section id = "concepts" class = "slide level2" >
< h2 > Concepts< / h2 >
< h2 > Concepts< / h2 >
< ul >
< ul >
< li > Repositories: A directory where you will be tracking changes.< / li >
< li > Repositories: A directory where you will be tracking
changes.< / li >
< li > Snapshots: A copy of the state of the repository at a given
< li > Snapshots: A copy of the state of the repository at a given
time.< / li >
time.< / li >
< li > Working Copy: Changes that haven’ t been recorded in a snapshot
< li > Working Copy: Changes that haven’ t been recorded in a snapshot
@ -338,9 +375,9 @@ yet.</li>
< / ol >
< / ol >
< p > The < code > git init< / code > command turned the current directory
< p > The < code > git init< / code > command turned the current directory
(< code > .< / code > ) into a git repository.< / p >
(< code > .< / code > ) into a git repository.< / p >
< p > If you were to type < code > git init repo_name< / code > it would create a
< p > If you were to type < code > git init repo_name< / code > it would
new directory named < code > repo_name/< / code > and then turn it into a git
create a new directory named < code > repo_name/< / code > and then turn
repo.< / p >
it into a git repo.< / p >
< / section >
< / section >
< section id = "configurations" class = "slide level2" >
< section id = "configurations" class = "slide level2" >
< h2 > Configurations< / h2 >
< h2 > Configurations< / h2 >
@ -389,7 +426,8 @@ doing and why.</li>
< / section >
< / section >
< section id = "lets-practice" class = "slide level2" >
< section id = "lets-practice" class = "slide level2" >
< h2 > Let’ s Practice< / h2 >
< h2 > Let’ s Practice< / h2 >
< p > Let’ s make personal wiki’ s to keep track of what we are doing.< / p >
< p > Let’ s make personal wiki’ s to keep track of what we are
doing.< / p >
< ol type = "1" >
< ol type = "1" >
< li > navigate to the < code > git_intro_download/< / code > directory.< / 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 >
@ -398,7 +436,8 @@ doing and why.</li>
< li > write something< / li >
< li > write something< / li >
< li > stage it< / li >
< li > stage it< / li >
< li > write a commit message and commit it.< / li >
< li > write a commit message and commit it.< / li >
< li > add some more files and edits and repeat steps 5-7 a few times.< / li >
< li > add some more files and edits and repeat steps 5-7 a few
times.< / li >
< / ol >
< / ol >
< / section >
< / section >
< section id = "git-log---noticing-what-happens" class = "slide level2" >
< section id = "git-log---noticing-what-happens" class = "slide level2" >
@ -423,8 +462,9 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb10-1"><a href=
< / section >
< / section >
< section id = "how-git-works" class = "slide level2" >
< section id = "how-git-works" class = "slide level2" >
< h2 > How Git Works< / h2 >
< h2 > How Git Works< / h2 >
< p > Please take notes in your wiki; saving, staging, and committing as
< p > Please take notes in your wiki; saving, staging, and committing
you go. Put each topic into it’ s own file; we will use them later.< / p >
as you go. Put each topic into it’ s own file; we will use them
later.< / p >
< p > If you run into issues, please let me know and I’ ll pause to
< p > If you run into issues, please let me know and I’ ll pause to
help.< / p >
help.< / p >
< p > I owe this approach to explaining git to < a
< p > I owe this approach to explaining git to < a
@ -433,24 +473,25 @@ Preston-Werner’ s Git Parable</a></p>
< / section >
< / section >
< section id = "snapshots" class = "slide level2" >
< section id = "snapshots" class = "slide level2" >
< h2 > Snapshots< / h2 >
< h2 > Snapshots< / h2 >
< p > When working with a project, you might want to know the history of
< p > When working with a project, you might want to know the history
that project. A simple way to do this is to make copies or snapshots at
of that project. A simple way to do this is to make copies or
regular or important points.< / p >
snapshots at regular or important points.< / p >
< blockquote >
< blockquote >
< p > Imagine I am writing a novel. I start by writing “It was a dark and
< p > Imagine I am writing a novel. I start by writing “It was a dark
stormy knight.” In order to avoid loosing my work, I save my working
and stormy knight.” In order to avoid loosing my work, I save my
version, and then make a copy to google drive called
working version, and then make a copy to google drive called
< code > novel-(date1).docx< / code > . Later I decide to fix my error and
< code > novel-(date1).docx< / code > . Later I decide to fix my error and
change it to “It was a dark and stormy night.” I then save my working
change it to “It was a dark and stormy night.” I then save my
version and make a second copy < code > novel-(date2).docx< / code > .< / p >
working version and make a second copy
< code > novel-(date2).docx< / code > .< / p >
< / blockquote >
< / blockquote >
< / section >
< / section >
< section id = "storing-objects" class = "slide level2" >
< section id = "storing-objects" class = "slide level2" >
< h2 > Storing Objects< / h2 >
< h2 > Storing Objects< / h2 >
< p > This is the basic way git works. Each time a file is committed, a
< p > This is the basic way git works. Each time a file is committed, a
copy is saved to a hidden directory in the < code > .git< / code > folder.
copy is saved to a hidden directory in the < code > .git< / code > folder.
Staging the file marks that you want to save the current version of the
Staging the file marks that you want to save the current version of
file.< / p >
the file.< / p >
< details >
< details >
< summary > Explore< / summary >
< summary > Explore< / summary >
In your wiki, stage a change for a file.
In your wiki, stage a change for a file.
@ -459,52 +500,54 @@ Now change the same file, and check 'git status' again.
The old version is staged, but the new one is not.
The old version is staged, but the new one is not.
< / details >
< / details >
< / section >
< / section >
< section id = "how-does-git-name-each-file-version" class = "slide level2" >
< section id = "how-does-git-name-each-file-version"
class="slide level2">
< h2 > How does git name each file version?< / h2 >
< h2 > How does git name each file version?< / h2 >
< p > There is a computer science tool called a < a
< p > There is a computer science tool called a < a
href="https://en.wikipedia.org/wiki/Hash_function">hash function< / a > . It
href="https://en.wikipedia.org/wiki/Hash_function">hash
allows us to give each version of a file a (nearly) unique name that
function< / a > . It allows us to give each version of a file a (nearly)
depends on the file’ s contents.< / p >
unique name that depends on the file’ s contents.< / p >
< ol type = "1" >
< ol type = "1" >
< li > Navigate to the < code > bash_exploration/< / code > directory.< / li >
< li > Navigate to the < code > bash_exploration/< / code > directory.< / li >
< li > run < code > sha1sum c.txt< / code > < / li >
< li > run < code > sha1sum c.txt< / code > < / li >
< li > Does it match
< li > Does it match
< code > cf44e4a24958c62790979deaad545d23c8fbe98e< / code > ?< / li >
< code > cf44e4a24958c62790979deaad545d23c8fbe98e< / code > ?< / li >
< li > Edit < code > c.txt< / code > by removing the ‘ (txt)’ part of the first
< li > Edit < code > c.txt< / code > by removing the ‘ (txt)’ part of the
line.< / li >
first line.< / li >
< li > What is the new sha1sum?< / li >
< li > What is the new sha1sum?< / li >
< / ol >
< / ol >
< p > This is called a Content Addressible System, because we can address
< p > This is called a Content Addressible System, because we can
each unique version of our content.< / p >
address each unique version of our content.< / p >
< / section >
< / section >
< section id = "incremental-snapshots" class = "slide level2" >
< section id = "incremental-snapshots" class = "slide level2" >
< h2 > Incremental Snapshots< / h2 >
< h2 > Incremental Snapshots< / h2 >
< p > Imagine if I had 100 different files, and I was taking full snapshots
< p > Imagine if I had 100 different files, and I was taking full
each time I changed one or two of them. I would end up with a lot of
snapshots each time I changed one or two of them. I would end up
copies of the same content.< / p >
with a lot of copies of the same content.< / p >
< p > If I wanted to save on storage space, I could instead copy just the
< p > If I wanted to save on storage space, I could instead copy just
versions that I changed.< / p >
the versions that I changed.< / p >
< p > This is what Git does. Each snapshot contains just a list of the
< p > This is what Git does. Each snapshot contains just a list of the
staged files, i.e. the files that we have said have changed in an
staged files, i.e. the files that we have said have changed in an
important way.< / p >
important way.< / p >
< p > This is done by saving the staged objects with SHA1SUM names, and
< p > This is done by saving the staged objects with SHA1SUM names, and
then writing a small file that contains the filenames and SHA1SUM names
then writing a small file that contains the filenames and SHA1SUM
of the change. This is what committing a change does.< / p >
names of the change. This is what committing a change does.< / p >
< / section >
< / section >
< section id = "constructing-a-dag---commit-parents" class = "slide level2" >
< section id = "constructing-a-dag---commit-parents"
class="slide level2">
< h2 > Constructing a DAG - Commit Parents< / h2 >
< h2 > Constructing a DAG - Commit Parents< / h2 >
< p > Now notice one problem with Incremental Snapshots. If I miss a
< p > Now notice one problem with Incremental Snapshots. If I miss a
snapshot somewhere, I am left without those changes. So, I need a way to
snapshot somewhere, I am left without those changes. So, I need a
know which previous snapshots are required to get to a specific
way to know which previous snapshots are required to get to a
state.< / p >
specific state.< / p >
< p > The solution is to allow commits to include information on
< p > The solution is to allow commits to include information on
< strong > ‘ parent’ < / strong > commits. Now we can draw a graph of how we get
< strong > ‘ parent’ < / strong > commits. Now we can draw a graph of how we
to a specific state.< / p >
get to a specific state.< / p >
< figure >
< figure >
< img data-src = "./SimpleCommitDAG.drawio.svg" alt = "Simple Commit DAG" / >
< img data-src = "./SimpleCommitDAG.drawio.svg"
alt="Simple Commit DAG" />
< figcaption aria-hidden = "true" > Simple Commit DAG< / figcaption >
< figcaption aria-hidden = "true" > Simple Commit DAG< / figcaption >
< / figure >
< / figure >
< p > < code > git log --graph< / code > describes the commit dag.< / p >
< / section >
< / section >
< section id = "confusing-dags" class = "slide level2" >
< section id = "confusing-dags" class = "slide level2" >
< h2 > Confusing DAGS< / h2 >
< h2 > Confusing DAGS< / h2 >
@ -518,8 +561,8 @@ alt="Complicated Commit DAG" />
< / section >
< / section >
< section id = "pointers-branches-tags-head" class = "slide level2" >
< section id = "pointers-branches-tags-head" class = "slide level2" >
< h2 > Pointers (branches, tags, HEAD)< / h2 >
< h2 > Pointers (branches, tags, HEAD)< / h2 >
< p > In CS, a pointer is something that records an address to something
< p > In CS, a pointer is something that records an address to
else.< / p >
something else.< / p >
< figure >
< figure >
< img data-src = "./ComplicatedCommitDAG_WithPointers.drawio.svg"
< img data-src = "./ComplicatedCommitDAG_WithPointers.drawio.svg"
alt="Complicated Commit DAG with Pointers" />
alt="Complicated Commit DAG with Pointers" />
@ -531,19 +574,20 @@ Pointers</figcaption>
< section id = "branches" class = "slide level2" >
< section id = "branches" class = "slide level2" >
< h2 > Branches< / h2 >
< h2 > Branches< / h2 >
< p > A branch is a flexible marker that simplifies isolating work from
< p > A branch is a flexible marker that simplifies isolating work from
different parts of the codebase. It is used to track areas of work. For
different parts of the codebase. It is used to track areas of work.
example, if I:< / p >
For example, if I:< / p >
< ul >
< ul >
< li > Wanted to experiment with something without messing with the main
< li > Wanted to experiment with something without messing with the
code.< / li >
main code.< / li >
< li > Was trying to fix a bug and needed to add a bunch of debugging.< / li >
< li > Was trying to fix a bug and needed to add a bunch of
< li > Wanted to try implementing a specific advisor’ s suggestions before
debugging.< / li >
going all in on it.< / li >
< li > Wanted to try implementing a specific advisor’ s suggestions
before going all in on it.< / li >
< li > Try to incorporate all the work of a collaborator who’ s work I’ m
< li > Try to incorporate all the work of a collaborator who’ s work I’ m
going to need to fix.< / li >
going to need to fix.< / li >
< / ul >
< / ul >
< p > When you create a commit, a branch will change to point to the new
< p > When you create a commit, a branch will change to point to the
commit.< / p >
new commit.< / p >
< blockquote >
< blockquote >
< p > Branches are cheap, use them.< / p >
< p > Branches are cheap, use them.< / p >
< / blockquote >
< / blockquote >
@ -554,16 +598,17 @@ commit.</p>
< ul >
< ul >
< li > Marking releases or versions of software.< / li >
< li > Marking releases or versions of software.< / li >
< li > Identifying a commit where an error was added.< / li >
< li > Identifying a commit where an error was added.< / li >
< li > In Economics: Marking the version of an analysis you presented in
< li > In Economics: Marking the version of an analysis you presented
your dissertation.< / li >
in your dissertation.< / li >
< / ul >
< / ul >
< / section >
< / section >
< section id = "head" class = "slide level2" >
< section id = "head" class = "slide level2" >
< h2 > HEAD< / h2 >
< h2 > HEAD< / h2 >
< p > Points to the commit that your current working copy is based on.< / p >
< p > Points to the commit that your current working copy is based
< p > You may see a < strong > detached HEAD< / strong > error. No the revolution
on.< / p >
hasn’ t started yet, you just got your HEAD pointing to a specific commit
< p > You may see a < strong > detached HEAD< / strong > error. No the
instead of a branch pointer.< / p >
revolution hasn’ t started yet, you just got your HEAD pointing to a
specific commit instead of a branch pointer.< / p >
< / section >
< / section >
< section id = "return-of-the-dag" class = "slide level2" >
< section id = "return-of-the-dag" class = "slide level2" >
< h2 > Return of the DAG< / h2 >
< h2 > Return of the DAG< / h2 >
@ -585,8 +630,8 @@ Pointers</figcaption>
alt="Complicated Commit DAG" />
alt="Complicated Commit DAG" />
< figcaption aria-hidden = "true" > Complicated Commit DAG< / figcaption >
< figcaption aria-hidden = "true" > Complicated Commit DAG< / figcaption >
< / figure >
< / figure >
< p > Take a look at < code > commit 10< / code > . Notice how it has to handle
< p > Take a look at < code > commit 10< / code > . Notice how it has to
the cases where< / p >
handle the cases where< / p >
< ul >
< ul >
< li > < code > Commit 5< / code > has removed < code > b.txt< / code > but
< li > < code > Commit 5< / code > has removed < code > b.txt< / code > but
< code > commit 9< / code > hasn’ t< / li >
< code > commit 9< / code > hasn’ t< / li >
@ -607,21 +652,23 @@ edits of <code>e.txt</code></li>
< / blockquote >
< / blockquote >
< 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
kept or removed. Resolving a conflict is part of merging branches.< / p >
be 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"
class="slide level2">
class="slide level2">
< h2 > Rewriting History - the DAG can be modified (kind of)< / h2 >
< h2 > Rewriting History - the DAG can be modified (kind of)< / h2 >
< p > Because the DAG is just a bunch of records pointing to other records,
< p > Because the DAG is just a bunch of records pointing to other
you can rewrite it, < strong > < em > BUT< / em > < / strong > if you rewrite a copy
records, you can rewrite it, < strong > < em > BUT< / em > < / strong > if you
of the DAG and your coworkers don’ t, then you’ re in for a world of
rewrite a copy of the DAG and your coworkers don’ t, then you’ re in
hurt.< / p >
for a world of hurt.< / p >
< p > This is what advanced GIT consists of: rewriting the commit DAG so
< p > This is what advanced GIT consists of: rewriting the commit DAG
that it clearly, cleanly, and consisely represents how the codebase
so that it clearly, cleanly, and consisely represents how the
grew.< / p >
codebase grew.< / p >
< p > We will only take the briefest of looks at one way to do that.< / p >
< p > We will only take the briefest of looks at one way to do
that.< / p >
< / section > < / section >
< / section > < / section >
< section >
< section >
< section id = "how-to-work-with-git" class = "title-slide slide level1" >
< section id = "how-to-work-with-git" class = "title-slide slide level1" >
@ -665,7 +712,8 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href=
< div class = "sourceCode" id = "cb14" > < pre
< div class = "sourceCode" id = "cb14" > < pre
class="sourceCode bash">< code class = "sourceCode bash" > < span id = "cb14-1" > < a href = "#cb14-1" aria-hidden = "true" tabindex = "-1" > < / a > < span class = "fu" > git< / span > checkout < span class = "at" > -b< / span > < span class = "pp" > [< / span > < span class = "ss" > new_branch_name< / span > < span class = "pp" > ]< / span > < / span >
class="sourceCode bash">< code class = "sourceCode bash" > < span id = "cb14-1" > < a href = "#cb14-1" aria-hidden = "true" tabindex = "-1" > < / a > < span class = "fu" > git< / span > checkout < span class = "at" > -b< / span > < span class = "pp" > [< / span > < span class = "ss" > new_branch_name< / span > < span class = "pp" > ]< / span > < / span >
< span id = "cb14-2" > < a href = "#cb14-2" aria-hidden = "true" tabindex = "-1" > < / a > < span class = "fu" > git< / span > switch < span class = "at" > -c< / span > < span class = "pp" > [< / span > < span class = "ss" > new_branch_name< / span > < span class = "pp" > ]< / span > < / span > < / code > < / pre > < / div >
< span id = "cb14-2" > < a href = "#cb14-2" aria-hidden = "true" tabindex = "-1" > < / a > < span class = "fu" > git< / span > switch < span class = "at" > -c< / span > < span class = "pp" > [< / span > < span class = "ss" > new_branch_name< / span > < span class = "pp" > ]< / span > < / span > < / code > < / pre > < / div >
< p > In our wiki repo, let’ s create a branch named < em > spellcheck< / em > < / p >
< p > In our wiki repo, let’ s create a branch named
< em > spellcheck< / em > < / p >
< pre class = "git" > < code > git checkout -b spellcheck< / code > < / pre >
< pre class = "git" > < code > git checkout -b spellcheck< / code > < / pre >
< p > Now check which branch we are on< / p >
< p > Now check which branch we are on< / p >
< div class = "sourceCode" id = "cb16" > < pre
< div class = "sourceCode" id = "cb16" > < pre
@ -701,8 +749,8 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb18-1"><a href=
< 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-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-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 >
< 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 don’ t
< p > This is called a fast-forward merge and occurrs when branches
have conflicts.< / p >
don’ t 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 >
@ -732,11 +780,12 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb19-1"><a href=
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 = "fu" > nano< / 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 “< < < < < ” “======”
< p > Note the symbols “< < < < < ” “======”
“> > > > > ”. These tell us what the differences are between
“> > > > > ”. These tell us what the differences are
the commits< / p >
between the commits< / p >
< p > To resolve the commit:< / p >
< p > To resolve the commit:< / p >
< ul >
< ul >
< li > we edit the files in conflict to get what we want from them.< / li >
< li > we edit the files in conflict to get what we want from
them.< / li >
< li > stage the changes.< / li >
< li > stage the changes.< / li >
< li > commit the merged files.< / li >
< li > commit the merged files.< / li >
< / ul >
< / ul >
@ -755,22 +804,22 @@ color. Notice that spellcheck didn’ t get the changes from main.</li>
< li > Resolve the merge.< / li >
< li > Resolve the merge.< / li >
< li > merge main into spellcheck at some point.< / 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
< p > Why would normal practice be to merge your release branch into
development branch, then merge back?< / p >
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 releases and branches that
< p > Usually, you have branches that represent releases and branches
represent areas you are working on.< / p >
that 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
work that you consider somewhat complete, i.e. when you have a first
present work that you consider somewhat complete, i.e. when you have
draft of your data processing code, or the output data.< / li >
a first draft of your data processing code, or the output data.< / li >
< li > < code > data_processing< / code > : This is where you write your data
< li > < code > data_processing< / code > : This is where you write your data
processing code, e.g. a web scraper and data munging tools. It might
processing code, e.g. a web scraper and data munging tools. It might
include a copy of a < code > .csv< / code > file or < code > .rdata< / code > file
include a copy of a < code > .csv< / code > file or < code > .rdata< / code >
that you will use in the analysis later.< / li >
file that you will use in the analysis later.< / li >
< li > < code > regression_analysis< / code > : This is where you develop the
< li > < code > regression_analysis< / code > : This is where you develop the
analysis that you will apply to the data you have. This will require
analysis that you will apply to the data you have. This will require
pulling the most recent data to analyze.< / li >
pulling the most recent data to analyze.< / li >
@ -780,29 +829,32 @@ pulling the most recent data to analyze.</li>
< p > What this might look like.< / p >
< p > What this might look like.< / p >
< ol type = "1" >
< ol type = "1" >
< li class = "fragment" > init repo< / li >
< li > init repo< / li >
< / ol >
< ol start = "2" type = "1" >
< li class = "fragment" > write things such as README in main.< / li >
< li class = "fragment" > write things such as README in main.< / 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
(committing along the way).< / li >
state (committing along the way).< / li >
< li class = "fragment" > merge main into data processing, fix conflicts,
< li class = "fragment" > merge main into data processing, fix conflicts,
then merge< code > data_processing< / code > into main.< / li >
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
from main.< / li >
< code > regression_analysis< / code > from main.< / li >
< li class = "fragment" > start writing your analysis, committing along the
< li class = "fragment" > start writing your analysis, committing along
way.< / li >
the way.< / li >
< li class = "fragment" > Notice that the data is incorrect.< / li >
< li class = "fragment" > Notice that the data is incorrect.< / li >
< li class = "fragment" > checkout < code > data_processing< / code > < / li >
< li class = "fragment" > checkout < code > data_processing< / code > < / li >
< li class = "fragment" > fix the error that is giving you the incorrect
< li class = "fragment" > fix the error that is giving you the incorrect
data< / li >
data< / li >
< li class = "fragment" > merge the fixes into main with a helpful
< li class = "fragment" > merge the fixes into main with a helpful
description.< / li >
description.< / li >
< li class = "fragment" > checkout < code > data_analysis< / code > and merge the
< li class = "fragment" > checkout < code > data_analysis< / code > and merge
fixes from main.< / li >
the fixes from main.< / li >
< li class = "fragment" > finish your analysis with the corrected data< / li >
< li class = "fragment" > finish your analysis with the corrected
data< / li >
< li class = "fragment" > push analysis to main.< / li >
< li class = "fragment" > push analysis to main.< / li >
< li class = "fragment" > Start a new branch < code > report< / code > and begin
< li class = "fragment" > Start a new branch < code > report< / code > and
writing your report.< / li >
begin writing your report.< / li >
< / ol >
< / ol >
< / section >
< / section >
< section id = "view-from-main-street" class = "slide level2" >
< section id = "view-from-main-street" class = "slide level2" >
@ -821,14 +873,14 @@ 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 = "cb22" > < pre
< 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 >
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
them into main by:< / p >
merge them into main by:< / p >
< div class = "sourceCode" id = "cb23" > < pre
< 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 >
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 >
< 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
it is squashed.< / p >
after it is squashed.< / p >
< / section > < / section >
< / section > < / section >
< section >
< section >
< section id = "remotes" class = "title-slide slide level1" >
< section id = "remotes" class = "title-slide slide level1" >
@ -837,21 +889,22 @@ it is squashed.</p>
< / section >
< / section >
< section id = "git-is-a-distributed-vcs" class = "slide level2" >
< section id = "git-is-a-distributed-vcs" class = "slide level2" >
< h2 > Git is a Distributed VCS< / h2 >
< h2 > Git is a Distributed VCS< / h2 >
< p > We have focused on the Version Control System portions of Git. Now it
< p > We have focused on the Version Control System portions of Git.
is time to look at how to use it as a “distributed” VCS and how to
Now it is time to look at how to use it as a “distributed” VCS and
collaborate together.< / p >
how to collaborate together.< / p >
< blockquote >
< blockquote >
< p > Git originated as a tool to develop the Linux Kernel. It is now the
< p > Git originated as a tool to develop the Linux Kernel. It is now
most popular VCS in the world. This is - in part - because people can
the most popular VCS in the world. This is - in part - because
work on the same thing without getting in each other’ s way.< / p >
people can work on the same thing without getting in each other’ s
way.< / p >
< / blockquote >
< / blockquote >
< p > Because Git is flexible, it supports many different workflows. When
< p > Because Git is flexible, it supports many different workflows.
you work with an established team, learn their workflow.< / p >
When you work with an established team, learn their workflow.< / p >
< / section >
< / section >
< section id = "adding-a-local-remote" class = "slide level2" >
< section id = "adding-a-local-remote" class = "slide level2" >
< h2 > Adding a local Remote< / h2 >
< h2 > Adding a local Remote< / h2 >
< p > A remote is somewhere that git will fetch commits from. A repository
< p > A remote is somewhere that git will fetch commits from. A
can have more than one remote.< / p >
repository can have more than one remote.< / p >
< blockquote >
< blockquote >
< p > A local remote is a remote that is on the same computer, e.g. a
< p > A local remote is a remote that is on the same computer, e.g. a
separate HDD or USB drive.< / p >
separate HDD or USB drive.< / p >
@ -891,15 +944,17 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb25-1"><a href=
< li > It already has a git repo on it.< / li >
< li > It already has a git repo on it.< / li >
< li > We are going to create a joint wiki.
< li > We are going to create a joint wiki.
< ul >
< ul >
< li > Each person chooses a topic or two from their personal wiki.< / li >
< li > Each person chooses a topic or two from their personal
< li > We will pass around the USB a couple of times, allowing people to
wiki.< / li >
< li > We will pass around the USB a couple of times, allowing people
to
< ul >
< ul >
< li > clone the repo< / li >
< li > clone the repo< / li >
< li > add their topics< / li >
< li > add their topics< / li >
< li > push to the repo< / li >
< li > push to the repo< / li >
< / ul > < / li >
< / ul > < / li >
< li > We will then divide into editing teams and I’ ll assign you a topic
< li > We will then divide into editing teams and I’ ll assign you a
or two that you will edit.< / li >
topic or two that you will edit.< / li >
< li > As we pass the USB around, you’ ll get a chance to pull and push
< li > As we pass the USB around, you’ ll get a chance to pull and push
changes.< / li >
changes.< / li >
< li > Talk as an editing team, but don’ t share computers.< / li >
< li > Talk as an editing team, but don’ t share computers.< / li >
@ -917,8 +972,8 @@ in Hari-up</a></p>
< p > A Git Forge provides< / p >
< p > A Git Forge provides< / p >
< ul >
< ul >
< li > A non-local git remote< / li >
< li > A non-local git remote< / li >
< li > features such as bug trackers and wiki’ s to help coordinate software
< li > features such as bug trackers and wiki’ s to help coordinate
development.< / li >
software development.< / li >
< / ul >
< / ul >
< / section >
< / section >
< section id = "demo-git-forge" class = "slide level2" >
< section id = "demo-git-forge" class = "slide level2" >
@ -941,9 +996,9 @@ development.</li>
< 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
after the lab is over. You will still have a local copy of the wiki
sometime after the lab is over. You will still have a local copy of
though!< / p >
the wiki though!< / p >
< / blockquote >
< / blockquote >
< / section > < / section >
< / section > < / section >
< section >
< section >
@ -956,10 +1011,10 @@ though!</p>
< ul >
< ul >
< li > < p > I have used git to track my code for both data processing and
< li > < p > I have used git to track my code for both data processing and
data analysis< / p > < / li >
data analysis< / p > < / li >
< li > < p > 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
some analyses, I might keep track of it in Git. A folder for each
code up some analyses, I might keep track of it in Git. A folder for
homework, tagging it right before submitting it. I would only use one
each homework, tagging it right before submitting it. I would only
branch probably.< / p > < / li >
use one branch probably.< / p > < / li >
< li > < p > 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.< / p > < / li >
project.< / p > < / li >
< li > < p > I use it to recover an analysis that I deleted by
< li > < p > I use it to recover an analysis that I deleted by
@ -969,28 +1024,30 @@ accident.</p></li>
multiple computers.< / p > < / li >
multiple computers.< / p > < / li >
< / ul >
< / ul >
< / 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 > < strong > .gitignore files< / strong > - Sometimes you don’ t want to
< li > < strong > .gitignore files< / strong > - Sometimes you don’ t want to
stage a whole class of files. A < code > .gitignore< / code > file tell git to
stage a whole class of files. A < code > .gitignore< / code > file tell
not to stage them. For example, if you are doing an analysis in python,
git to not to stage them. For example, if you are doing an analysis
you might get a < code > __pycache__/< / code > directory. If you put a line
in python, you might get a < code > __pycache__/< / code > directory. If
that says < code > */__pycache__/< / code > in your < code > .gitignore< / code > ,
you put a line that says < code > */__pycache__/< / code > in your
it will not be suggested that you stage anything in that directory.< / li >
< code > .gitignore< / code > , it will not be suggested that you stage
< li > < strong > Git LFS< / strong > - Saving large files that are not text can
anything in that directory.< / li >
be difficult, such as when you are saving < code > .pdf< / code > ,
< 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 > .jpg< / code > , < code > .png< / code > ,< code > .xlsx< / code > ,
< code > .docx< / code > , or < code > .zip< / code > files. Any change will cause
< code > .docx< / code > , or < code > .zip< / code > files. Any change will
the whole thing to be resaved, and this can quickly add up to lots of
cause the whole thing to be resaved, and this can quickly add up to
storage being used. Git LFS does a couple of things to reduce how much
lots of storage being used. Git LFS does a couple of things to
storage will be used.< / li >
reduce how much storage will be used.< / li >
< li > < strong > Branching Strategies< / strong > - Knowing how to setup and use
< li > < strong > Branching Strategies< / strong > - Knowing how to setup and
branches properly is a powerful thing. There are tons of blogs with
use branches properly is a powerful thing. There are tons of blogs
information from different companies explaining how they are doing
with information from different companies explaining how they are
it.< / li >
doing it.< / li >
< li > < strong > Advanced Merging and Rebasing< / strong > - There is so much to
< li > < strong > Advanced Merging and Rebasing< / strong > - There is so
do here.< / li >
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" >
@ -1002,11 +1059,11 @@ do here.</li>
< figure >
< figure >
< img data-src = "https://imgs.xkcd.com/comics/git.png"
< img data-src = "https://imgs.xkcd.com/comics/git.png"
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." />
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." />
< figcaption aria-hidden = "true" > If that doesn’ t fix it, git.txt contains
< figcaption aria-hidden = "true" > If that doesn’ t fix it, git.txt
the phone number of a friend of mine who understands git. Just wait
contains the phone number of a friend of mine who understands git.
through a few minutes of ‘ It’ s really pretty simple, just think of
Just wait through a few minutes of ‘ It’ s really pretty simple, just
branches as…’ and eventually you’ ll learn the commands that will fix
think of branches as…’ and eventually you’ ll learn the commands that
everything.< / figcaption >
will fix everything.< / figcaption >
< / figure >
< / figure >
< p > I’ m sorry, you just became the local git expert…< / p >
< p > I’ m sorry, you just became the local git expert…< / p >
< / section >
< / section >
@ -1015,18 +1072,18 @@ everything.</figcaption>
< ul >
< ul >
< li > Git is a useful tool to keep track of software versions and
< li > Git is a useful tool to keep track of software versions and
coordinate work.< / li >
coordinate work.< / li >
< li > Most of the time you can get away with just memorizing some basic
< li > Most of the time you can get away with just memorizing some
commands and workflow< / li >
basic commands and workflow< / li >
< li > When things are hard, remember
< li > When things are hard, remember
< ul >
< ul >
< li > The basic model of how it works. Try to figure out what went
< li > The basic model of how it works. Try to figure out what went
wrong.< / li >
wrong.< / li >
< li > DuckDuckGo search is your friend. Google might be as well.< / li >
< li > DuckDuckGo search is your friend. Google might be as well.< / li >
< li > ChatGPT/Claude.ai are pretty good at explaining errors, commands,
< li > ChatGPT/Claude.ai are pretty good at explaining errors,
etc.< / li >
commands, etc.< / li >
< / ul > < / li >
< / ul > < / li >
< li > Don’ t commit anything that needs to remain secret. It is rather hard
< li > Don’ t commit anything that needs to remain secret. It is rather
to delete something from a Git repo.< / li >
hard to delete something from a Git repo.< / li >
< / ul >
< / ul >
< / section >
< / section >
< section id = "feedback" class = "slide level2" >
< section id = "feedback" class = "slide level2" >
@ -1036,7 +1093,29 @@ to delete something from a Git repo.</li>
< li > What would you like to keep practicing?< / li >
< li > What would you like to keep practicing?< / li >
< li > How could I improve this presentation?< / li >
< li > How could I improve this presentation?< / li >
< / ul >
< / ul >
< / section >
< section id = "license" class = "slide level2" >
< h2 > License< / h2 >
< p xmlns:cc = "http://creativecommons.org/ns#" xmlns:dct = "http://purl.org/dc/terms/" >
< a property = "dct:title" rel = "cc:attributionURL" href = "https://git.youainti.com/Teaching/git-introduction" > Introduction to Version Control Systems (GIT) for Economists< / a >
by
< a rel = "cc:attributionURL dct:creator" property = "cc:attributionName" href = "https://www.youainti.com" > Will King< / a >
is licensed under < a href = "https://creativecommons.org/licenses/by-nc-sa/4.0/?ref=chooser-v1" target = "_blank" rel = "license noopener noreferrer" style = "display:inline-block;" > CC BY-NC-SA 4.0< img style = "height:22px!important;margin-left:3px;vertical-align:text-bottom;" src = "https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1" alt = "" > < img style = "height:22px!important;margin-left:3px;vertical-align:text-bottom;" src = "https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1" alt = "" > < img style = "height:22px!important;margin-left:3px;vertical-align:text-bottom;" src = "https://mirrors.creativecommons.org/presskit/icons/nc.svg?ref=chooser-v1" alt = "" > < img style = "height:22px!important;margin-left:3px;vertical-align:text-bottom;" src = "https://mirrors.creativecommons.org/presskit/icons/sa.svg?ref=chooser-v1" alt = "" > < / a > < / p >
< / section > < / section >
< / section > < / section >
< div class = "license-footer" style = "position: fixed; top: 5px; right: 5px; z-index: 1000;" >
< a href = "#" class = "license-icons" data-toggle = "license-tooltip" >
< img style = "height:16px; margin-left:2px;" src = "https://mirrors.creativecommons.org/presskit/icons/cc.svg" alt = "CC" >
< img style = "height:16px; margin-left:2px;" src = "https://mirrors.creativecommons.org/presskit/icons/by.svg" alt = "BY" >
< img style = "height:16px; margin-left:2px;" src = "https://mirrors.creativecommons.org/presskit/icons/nc.svg" alt = "NC" >
< img style = "height:16px; margin-left:2px;" src = "https://mirrors.creativecommons.org/presskit/icons/sa.svg" alt = "SA" >
< / a >
< div class = "license-tooltip" >
Introduction to Git for Economists by Will King is licensed under CC BY-NC-SA 4.0
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
@ -1199,6 +1278,24 @@ to delete something from a Git repo.</li>
RevealZoom
RevealZoom
]
]
});
});
< / script >
< script >
Reveal.addEventListener('ready', function(event) {
var licenseIcons = document.querySelector('.license-icons');
var licenseTooltip = document.querySelector('.license-tooltip');
licenseIcons.addEventListener('mouseover', function() {
licenseTooltip.style.display = 'block';
});
licenseIcons.addEventListener('mouseout', function() {
licenseTooltip.style.display = 'none';
});
licenseIcons.addEventListener('click', function(e) {
e.preventDefault();
});
});
< / script >
< / script >
< / body >
< / body >
< / html >
< / html >