Git's interface can seem weird, mainly because it is. I think that understanding a bit about how Git works under the hood helps with understanding why some of the commands do what they do.
I have done this
Git has a reputation for being hard.
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}
@ -58,30 +90,171 @@
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.
}
\end{frame}
\begin{frame}
\frametitle{Let's avoid this}
\dirtree{%
.1 Project.
.2 draft.
.3 some.
.3 files.
.2 final-draft.
.3 some.
.3 files.
.2 final.
.3 some.
.3 files.
.2 real-final.
.3 some.
.3 files.
.2 actual-real-final.
.3 some.
.3 files.
}
\note{%
I think, being honest, we have all done this. This sort of works, if you're working on something by yourself. Once you start collaborating on software, you are going to have a bad time.
However, this is a simple approach and not a million miles from what Git does internally.
I want this to be quite interactive so first things first, let's get Git setup.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Install}
\begin{minted}{bash}
# Ubuntu / Debian / Kali
sudo apt install git
# Centos / Fedora / Red Hat
sudo dnf install git
# Arch / Antergos / Manjaro
sudo pacman -S git
# Mac
brew install git
\end{minted}
\href{https://gitforwindows.org/}{Git for Windows: https://gitforwindows.org/}
\note{%
Git is probably already installed if you are on a Linux system. However, if not, it will definitely be in your standard repositories.
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 Git installed. I will be running it on Linux although the commands should all be the same for Windows and Mac.
Note that I am not using my primary email address. The email address you provide here will be available to anyone with access to repositories you work on.
These settings are stored in \mintinline{bash}{~/.gitconfig}.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Setting It Up}
\framesubtitle{Editor}
\textbf{Pick One}
\begin{minted}{bash}
# Set editor to nano
git config --global core.editor "nano"
# Set editor to VS Code
git config --global core.editor "code -w"
# Set editor to Sublime
git config --global core.editor "subl -w"
\end{minted}
\note{%
There are several times that Git will need to open a text editor. By default, it will use \mintinline{bash}{EDITOR}. If neither is set, it will use VI.
Note that if you are using a GUI editor, you might have to set the wait flag. This makes it so the executable doesn't return until you close it.
}
\end{frame}
\begin{frame}[fragile]
\frametitle{Create a repository}
\begin{minted}{bash}
mkdir Project
cd Project
git init
\end{minted}
\note{%
Do this in a live terminal. MAKE SURE YOU MAKE YOUR FONT BIGGER
Show that the \mintinline{bash}{.git} folder has been created and do a tree to show what is in it.