\documentclass{beamer}


\usepackage{pgfpages}
%showNotes%\setbeameroption{show notes on second screen=right}
%\setbeamertemplate{note page}{\pagecolor{yellow!5}\insertnote}
\setbeamertemplate{note page}{\setlength{\parskip}{12pt}\pagecolor{yellow!5}\vfill\insertnote\vfill}
\setlength{\parskip}{12pt}
\usepackage{palatino}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{pdfpages}
\usepackage{dirtree}
\usepackage{csquotes}
%\usepackage{gitdags}
\usepackage{minted}
\setminted{%
	autogobble,
	fontsize=\footnotesize,
	breaklines
}

\usetheme{default}
\beamertemplatenavigationsymbolsempty
\hypersetup{pdfpagemode=UseNone} % don't show bookmarks on initial view

%\lstset{%
%  breaklines=true,
%  postbreak=\mbox{$\hookrightarrow$\space},
%  basicstyle=\footnotesize,
%  %keywordstyle=\color{blue},
%  morekeywords=git
%}
\usepackage{graphicx}
\graphicspath{ {./auto-images/} }

\makeatletter
\def\input@path{{auto-images/}}
%or: \def\input@path{{/path/to/folder/}{/path/to/other/folder/}}
\makeatother

%Information to be included in the title page:
\title{Git}
\author{Jonathan Hodgson (Archie)}
\date{\today}



\begin{document}

\frame{\titlepage}

\note{%
	A few people recently have asked me about Git.

	Git has become the de-facto for most situations.

	Microsoft recently moved to git for version controlling Windows and Office.
}

\begin{frame}
\frametitle{Obligitary XKCD Comic}
	\begin{center}
		\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1597.png}
	\end{center}
	\note{%
		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}

\begin{frame}
	\frametitle{Why bother?}
	
	\begin{itemize}
		\item Keep track of source code (or other folders and files)
		\item Facilitate collaboration
	\end{itemize}

	\note{%
		This applies to most (if not all) version control systems.

		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.
	}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Setting It Up}
	\framesubtitle{User}

	\begin{minted}{bash}
		git config --global user.name "Jonathan Hodgson"
		git config --global user.email "git@jonathanh.co.uk"
	\end{minted}

	\note{%
		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.
	}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Git status}
	\begin{minted}{bash}
		git status
	\end{minted}
	
	\begin{center}
		\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-shell-git-status.pdf}
	\end{center}
\end{frame}

\begin{frame}
	\frametitle{Terminology}

	\textbf{Blob} In Git, a file is called a blob.

	\textbf{Tree} In Git, a directory is called a tree.

	\textbf{Root} The top level directory is called the root.
	
	\note{%
		Pretty simple stuff.

		Because we don't have enough roots in Linux. :/

		Now we can start doing stuff
	}
\end{frame}



\begin{frame}
	\frametitle{Commits}
	\begin{center}
		\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1296.png}
	\end{center}
\end{frame}

\begin{frame}
	\frametitle{Commit Messages}
	\begin{center}
		\includegraphics[width=\textwidth,height=0.8\textheight,keepaspectratio]{auto-xkcd-1296.png}
	\end{center}
\end{frame}

\begin{frame}
	\frametitle{When should you commit?}
	
\end{frame}

\end{document}
