It's interface abstracts away a lot of the work, meaning it's commands can feel like magic. When it works, this is fine but unfortunately when things go wrong, you can be left - like in this comic - with no idea how to proceed.
I think that understanding a bit about how Git works under the hood will help de-mistily it.
Git's data model is actually quite simple. Understanding the basics of this can really help.
}
\end{frame}
\begin{frame}
\frametitle{Why bother?}
A very versatile Version Control System
\begin{itemize}
\item Keep track of source code (or other folders and files)
\item Keep track of source code (or other folders and files) and its history
\item Facilitate collaboration
\item Distributed
\end{itemize}
\note{%
This applies to most (if not all) version control systems.
Git is still being developed.
Being distributed means you can work on repositories offline (Unlike SVN).
It's useful even if you're working on things by your self. This presentation is version controlled.
You can use it to find out when something broke. I won't be covering it today but there is a tool called git bisect that can take a unit test (or script) to analyse when something broke using a binary search.
I think with a lot of tools that we use, having a deeper understanding of how they work means that we can use them better.
It's interface abstracts away a lot of the work, meaning it's commands can feel like magic. When it works, this is fine but unfortunately when things go wrong, you can be left - like in this comic - with no idea how to proceed.
It's interface can be confusing, there are some commands that do a lot (checkout) and there are often multiple ways to achieve something.
I think that understanding a bit about how Git works under the hood will help de-mistily it.
Git's data model is actually quite simple (beautiful even). Understanding the basics of this can really help.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Install}
@ -121,6 +128,9 @@
# Mac
brew install git
# Get the Version
git --version
\end{minted}
\href{https://gitforwindows.org/}{Git for Windows: https://gitforwindows.org/}
@ -131,6 +141,8 @@
There is a version of Git provided with xcode, but it is old. Most of the stuff we cover today should still work but (for example) some things need to be run from the root directory in old versions of git that don't in newer versions.
If you have the misfortune to be using windows, I've heard good things about Git for Windows but have not used it personally. It includes Bash emulation.
Hopefully you have a version greater than 2.23.0 - if not, it's not the end of the world.
}
\end{frame}
@ -272,7 +284,7 @@
\note{%
\begin{itemize}
\item This is a simple representation of the folder structure we saw, although for simplicity, I'm only showing 3 revisions.
\item Notice that so the computer knows the order, somewhere in each "snapshot", we include a reference to the previous snapshot
\item Notice that so the computer knows the order, somewhere in each ``snapshot", we include a reference to the previous snapshot
\end{itemize}
}
\end{frame}
@ -378,6 +390,8 @@
\end{center}
\note{%
Create repo and create a file called greeting.py. Make sure to mark it as executable.
Here we see the branch we are on (Master), we are told that there are no commits yet and we see that Git can see the file we've just made but it isn't tracking it.
Here can use git status to see what is in the staging area. They are listed in the "Changes to be committed" section. By default, they will also be green if you have colour switched on.
Here can use git status to see what is in the staging area. They are listed in the ``Changes to be committed" section. By default, they will also be green if you have colour switched on.
}
\end{frame}
@ -424,7 +438,7 @@
\begin{itemize}
\item Normally in contributing.md or similar
\end{itemize}
\item Use the imperative: "Fix bug" and not "Fixed bug" or "Fixes bug."
\item Use the imperative: ``Fix bug" and not ``Fixed bug" or ``Fixes bug."
\item References are stored in the \mintinline{bash}{.git/refs} folder
\item The \mintinline{bash}{heads} folder contains references to the heads (or tips) of all local branches
\end{itemize}
\note{%
}
\end{frame}
\begin{frame}
\frametitle{References}
\framesubtitle{HEAD}
\begin{itemize}
\item The HEAD references is directly in the \mintinline{bash}{.git} folder.
\item It refers to the ``current" commit. It is how git knows where you are.
\item This normally refers to a branch's head commit.
\item In some situations it will refer to a commit directly.
\end{itemize}
\note{%
Not sure why it is not in refs folder
If it refers directly to a commit, the repository is in what is called a ``detached head" state.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{.gitignore}
This file tells git which files not to track.
\begin{minted}{bash}
*.log
*.doc
*.pem
*.docx
*.jpg
*.jpeg
*.pdf
*.png
.DS_Store/
*.min.css
*.min.js
dist/
\end{minted}
\note{%
This will not stop git tracking a file if it's already being tracked.
If you start tracking large binary files, git isn't going to be able to compress them. This will result in a massive repo and a headache for everyone. If at all possible, don't track large files, especially if they are going to be changed. Remember, git stores each version of each file. With text, this is fine as it can be compressed efficiently. If it's not text, it can't.
You should probably also try to avoid including minified files as git won't be able to merge them automatically.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Branches}
\begin{itemize}
\item Allows multiple features to be developed in parallel without interference.
\item Allows multiple people to collaborate easily.
Branches are represented in git as references in the heads folder.
They can be created by simply creating a file there.
The git checkout command does A LOT of stuff. It can be confusing so it's functionality has been split up into several smaller commands. If you have git 2.23.0 or newer, you will be able to use it.
Be aware that a lot of tutorials etc. will use the checkout command. Version 2.23.0 was released in August 2019.