Commit 44550afe authored by Jeroen F.J. Laros's avatar Jeroen F.J. Laros

New style presentation template.

parent fbb15197
\documentclass[slidestop]{beamer}
\author{Jeroen F.J. Laros}
\title{Git Basics}
\providecommand{\mySubTitle}{}
\providecommand{\myConference}{Git course}
\providecommand{\myDate}{Monday, June 23, 2014}
\author{Jeroen F. J. Laros}
\providecommand{\myGroup}{Leiden Genome Technology Center}
\providecommand{\myGroup}{}
\providecommand{\myDepartment}{Department of Human Genetics}
\providecommand{\myCenter}{Center for Human and Clinical Genetics}
\providecommand{\lastCenterLogo}{
\raisebox{-0.1cm}{
\includegraphics[height=1cm]{lgtc_logo}
%\includegraphics[height=0.7cm]{ngi_logo}
}
}
\providecommand{\lastRightLogo}{
%\includegraphics[height=0.7cm]{nbic_logo}
%\includegraphics[height=0.8cm]{nwo_logo_en}
%\hspace{1.5cm}\includegraphics[height=0.7cm]{gen2phen_logo}
}
\input{../shared/shared.tex}
\usetheme{lumc}
......@@ -26,102 +17,82 @@
% This disables the \pause command, handy in the editing phase.
%\renewcommand{\pause}{}
% Make the title page.
\bodytemplate
% Make the title slide.
\makeTitleSlide{\includegraphics[width=3.5cm]{git_logo}}
% First page of the presentation.
\section{Initialisation}
\begin{frame}[fragile]
\frametitle{Starting a project.}
\subsection{Starting a project}
\begin{pframe}
Creating a new repository is easy. You do not need a server, no registration,
etc.
\bigskip
\begin{lstlisting}[language=none, caption=Make a new repository.]
$ cd ~/projects
$ git init
Initialized empty Git repository in <path>/.git/
\end{lstlisting}
\bigskip
\pause
Or you can ``clone'' an existing repository.
\bigskip
\begin{lstlisting}[language=none, caption=Clone an existing repository.]
$ git clone <path-to-repository>
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Starting a project.}
\end{pframe}
\begin{pframe}
You can see a hidden directory in a Git repository.
\bigskip
\begin{lstlisting}[language=none, caption=A hidden directory is added.]
$ ls -a
. .. .git
\end{lstlisting}
\bigskip
This directory contains almost everything that Git stores and manipulates.
\end{frame}
\end{pframe}
\section{Manipulation}
\begin{frame}
\frametitle{Local operations.}
\subsection{Local operations}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.8\textheight]{pics/18333fig0106-tn}
\includegraphics[height=0.7\textheight]{18333fig0106-tn}
\end{center}
\caption{Working directory, staging area, and Git directory.}
\label{}
\end{figure}
\end{frame}
\begin{frame}[fragile]
\frametitle{Checking the status of your files.}
\end{pframe}
\subsection{Checking the status of your files}
\begin{pframe}
\begin{lstlisting}[language=none, caption=Check status.]
$ git status
nothing to commit (working directory clean)
\end{lstlisting}
\bigskip
``\bt{git status}'' can tell you whether your files are:
``\lstinline{git status}'' can tell you whether your files are:
\begin{itemize}
\item Untracked.
\item Unmodified.
\item Modified.
\item Staged.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Checking the status of your files.}
\end{pframe}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.8\textheight]{pics/18333fig0201-tn}
\includegraphics[height=0.7\textheight]{18333fig0201-tn}
\end{center}
\caption{The lifecycle of the status of your files.}
\label{}
\end{figure}
\end{frame}
\begin{frame}[fragile]
\frametitle{Adding, removing, renaming.}
\end{pframe}
\subsection{Adding, removing, renaming}
\begin{pframe}
\begin{lstlisting}[language=none, caption=This file is not tracked.]
$ echo First version. > README
$ git status
# Untracked files:
# README
\end{lstlisting}
\bigskip
\pause
\begin{lstlisting}[language=none, caption=Now the file will be tracked.]
......@@ -130,19 +101,16 @@
# Changes to be committed:
# new file: README
\end{lstlisting}
\bigskip
To rename a file, use ``\bt{git mv}'', to remove, use ``\bt{git rm}''.
\end{frame}
To rename a file, use ``\lstinline{git mv}'', to remove, use
``\lstinline{git rm}''.
\end{pframe}
\section{Working with versions}
\begin{frame}[fragile]
\frametitle{commit}
\subsection{commit}
\begin{pframe}
Once you have modified your files and added them to the \emph{staging area},
you can commit them (add them to the repository).
\bigskip
\begin{lstlisting}[language=none, caption=Commit a new version.]
$ git commit
\end{lstlisting}
......@@ -152,20 +120,16 @@
\begin{itemize}
\item Useful when you want to search.
\end{itemize}
\bigskip
\pause
\begin{lstlisting}[language=none, caption=Commit a new version.]
$ git commit -m "Solved the counting bug."
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Undoing changes.}
\end{pframe}
\subsection{Undoing changes}
\begin{pframe}
Sometimes you will accidentally add a file.
\bigskip
\begin{lstlisting}[language=none, caption=Adding a new version of a file.]
$ echo Second version. > README
$ git add README
......@@ -173,63 +137,50 @@
# Changes to be committed:
# modified: README
\end{lstlisting}
\bigskip
\pause
If you want to undo this, you can use ``\bt{git reset}''.
\bigskip
If you want to undo this, you can use ``\lstinline{git reset}''.
\begin{lstlisting}[language=none, caption=Unstage a file.]
$ git reset README
$ git status
# Changes not staged for commit:
# modified: README
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Undoing changes.}
\end{pframe}
Keep in mind that ``\bt{git reset}'' by default sets a staged file back to unstaged.
\begin{pframe}
Keep in mind that ``\lstinline{git reset}'' by default sets a staged file
back to unstaged.
\begin{lstlisting}[language=none, caption=Unstage a file.]
$ git reset README
$ git status
# Changes not staged for commit:
# modified: README
\end{lstlisting}
\bigskip
\pause
To discard all changes in an unstaged file, you can use ``\bt{git checkout}''
To discard all changes in an unstaged file, you can use
``\lstinline{git checkout}''
\begin{lstlisting}[language=none, caption=Discarding changes.]
$ git checkout -- .
$ git status
nothing to commit, working directory clean
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Undoing changes.}
\end{pframe}
\begin{pframe}
For now, let's commit our change and move on.
\bigskip
\begin{lstlisting}[language=none, caption=Adding a new version of a file.]
$ echo Second version. > README
$ git commit
$ git status
nothing to commit, working directory clean
\end{lstlisting}
\bigskip
\end{frame}
\begin{frame}[fragile]
\frametitle{Viewing the history.}
To see the history of your project, use ``\bt{git log}''.
\bigskip
\end{pframe}
\subsection{Viewing the history}
\begin{pframe}
To see the history of your project, use ``\lstinline{git log}''.
\begin{lstlisting}[language=none, caption=The log of our project.]
$ git log
commit cc61ee7cd72590f3bebcc9e1ff3e9435c7f7dd28
......@@ -244,36 +195,29 @@
First version.
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Undo a commit.}
\end{pframe}
\subsection{Undo a commit}
\begin{pframe}
Sometimes we want to undo an entire commit. This is done with
``\bt{git revert}''.
\bigskip
``\lstinline{git revert}''.
\begin{lstlisting}[language=none, caption=Revert a commit.]
$ git revert cc61ee7cd72590f3bebcc9e1ff3e9435c7f7dd28
$ git revert cc61ee7cd7
$ cat README
First version.
\end{lstlisting}
\bigskip
The hash can be found with ``\bt{git log}''.
The hash can be found with ``\lstinline{git log}''.
\bigskip
\pause
You can also use a unique prefix of this hash, usually six characters is
enough.
\end{frame}
\begin{frame}[fragile]
\frametitle{Viewing changes in detail.}
If you want to see what has changed, use ``\bt{git diff}''.
\bigskip
\end{pframe}
\subsection{Viewing changes in detail}
\begin{pframe}
If you want to see what has changed, use ``\lstinline{git diff}''.
\begin{lstlisting}[language=none, caption=Difference between the working copy
and the staging area.]
$ echo Third version. > README
......@@ -284,24 +228,18 @@
-First version.
+Third version.
\end{lstlisting}
\bigskip
\pause
For staged files, use the ``\bt{--cached}'' or ``\bt{--staged}'' option.
\bigskip
For staged files, use the ``\lstinline{--cached}'' or
``\lstinline{--staged}'' option.
\begin{lstlisting}[language=none, caption=Difference between the staging area
and the last commit.]
$ git diff --cached
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Viewing changes in detail.}
\end{pframe}
\begin{pframe}
You can see the differences between any two versions.
\bigskip
\begin{lstlisting}[language=none, caption=Difference between the working copy
and an other commit.]
$ git diff cc61ee
......@@ -311,30 +249,28 @@
-Second version.
+Third version.
\end{lstlisting}
\bigskip
\pause
\begin{lstlisting}[language=none, caption=Difference between two committed
versions.]
$ git diff 8e10be cc61ee
\end{lstlisting}
\end{frame}
\end{pframe}
\section{Extras}
\begin{frame}[fragile]
\frametitle{Explicit no tracking.}
\subsection{Explicit no tracking}
\begin{pframe}
Sometimes you do not want to track certain files:
\begin{itemize}
\item Executables.
\item \bt{pdf} files (if you still have the \LaTeX\ source).
\item Python bytecode (\bt{.pyc}) files.
\item PDF files (if you still have the \LaTeX\ source).
\item Python bytecode (\lstinline{.pyc}) files.
\item Files containing passwords.
\end{itemize}
\bigskip
\medskip
\pause
Use the special ``\bt{.gitignore}'' file.
Use the special ``\lstinline{.gitignore}'' file.
\begin{lstlisting}[language=none, caption=Ignoring certain files.]
$ touch notrack.txt
$ echo notrack.txt > .gitignore
......@@ -343,46 +279,35 @@
$ git status
nothing to commit, working directory clean
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Help.}
With the ``\bt{help}'' command get the manual of a particular subcommand.
\bigskip
\end{pframe}
\subsection{Help}
\begin{pframe}
With the ``\lstinline{help}'' command get the manual of a particular
subcommand.
\begin{lstlisting}[language=none, caption=Get the full manual.]
$ git help <command>
\end{lstlisting}
\bigskip
\pause
Example.
\bigskip
\begin{lstlisting}[language=none, caption=Get the manual for the diff
subcommand.]
$ git help diff
\end{lstlisting}
\end{frame}
\section{Questions?}
\lastpagetemplate
\begin{fframe}
\begin{center}
Acknowledgements:
\bigskip
\bigskip
\end{pframe}
Martijn Vermaat
Zuotian Tatum
Wibowo Arindrarto
\makeAcknowledgementsSlide{
\begin{tabular}{l}
\acknowledgements
\end{tabular}
\bigskip
\end{center}
\hfill\includegraphics[width=3.5cm]{git_logo}
\vfill
\permfoot{http://git-scm.com/book}
\end{fframe}
\begin{tabular}{l}
\small\url{http://git-scm.com/book}\\
\end{tabular}
}
\end{document}
../presentation/gen2phen_logo.eps
\ No newline at end of file
../shared/git_logo.png
\ No newline at end of file
../presentation/lgtc_logo.eps
\ No newline at end of file
../presentation/logos/
\ No newline at end of file
../presentation/lumc_logo.eps
\ No newline at end of file
../presentation/lumc_logo_small.eps
\ No newline at end of file
../presentation/nbic_logo.eps
\ No newline at end of file
../presentation/ngi_logo.eps
\ No newline at end of file
../presentation/nwo_logo_en.eps
\ No newline at end of file
../pics/
\ No newline at end of file
../presentation/ul_logo.eps
\ No newline at end of file
\documentclass[slidestop]{beamer}
\author{Martijn Vermaat}
\title{Working with branches in Git}
\providecommand{\mySubTitle}{}
\providecommand{\myConference}{Git course}
\providecommand{\myDate}{Monday, June 23, 2014}
\author{Martijn Vermaat}
\providecommand{\myGroup}{Leiden Genome Technology Center}
\providecommand{\myGroup}{}
\providecommand{\myDepartment}{Department of Human Genetics}
\providecommand{\myCenter}{Center for Human and Clinical Genetics}
\providecommand{\lastCenterLogo}{
\raisebox{-0.1cm}{
\includegraphics[height=1cm]{lgtc_logo}
%\includegraphics[height=0.7cm]{ngi_logo}
}
}
\providecommand{\lastRightLogo}{
%\includegraphics[height=0.7cm]{nbic_logo}
%\includegraphics[height=0.8cm]{nwo_logo_en}
%\hspace{1.5cm}\includegraphics[height=0.7cm]{gen2phen_logo}
}
\input{../shared/shared.tex}
\usetheme{lumc}
......@@ -33,7 +24,7 @@
{
\begin{frame}
\frametitle{Table of contents}
\tableofcontents[currentsection]
\tableofcontents[currentsection, subsectionstyle=hide/hide]
\end{frame}
}
......@@ -43,129 +34,139 @@
%\renewcommand{\pause}{}
% Make the title page.
\bodytemplate
\makeTitleSlide{\includegraphics[width=3.5cm]{git_logo}}
\section{The Git commit graph}
\subsection{A linear history}
\begin{pframe}
\includegraphics[width=10cm]{linear}
\smallskip
\begin{frame}
\frametitle{A linear history}
\includegraphics[width=10cm]{images/linear}
\begin{itemize}
\item Every commit has a parent.
\item {\em Committing} creates a new commit on top of the current one.
\end{itemize}
\end{frame}
\end{pframe}
\subsection{The default \lstinline{master} branch}
\begin{pframe}
\includegraphics[width=10cm]{master}
\smallskip
\begin{frame}
\frametitle{The default \bt{master} branch}
\includegraphics[width=10cm]{images/master}
\begin{itemize}
\item A {\em branch} is a pointer to a commit.
\item By default there is one branch: \bt{master}.
\item By default there is one branch: \lstinline{master}.
\end{itemize}
\end{frame}
\end{pframe}
\begin{frame}
\frametitle{The current commit: \bt{HEAD}}
\subsection{The current commit: \lstinline{HEAD}}
\begin{pframe}
\begin{itemize}
\item The current commit is called \bt{HEAD} (shown in blue here).
\item \bt{HEAD} is actually a pointer to the current branch.
\item The current commit is called \lstinline{HEAD} (shown in blue here).
\item \lstinline{HEAD} is actually a pointer to the current branch.
\item (Or to the current commit if there is no current branch -- this is
called detached head state.)
\end{itemize}
\vspace{1cm}
\includegraphics[width=10cm]{images/head}
\end{frame}
\bigskip
\includegraphics[width=10cm]{head}
\end{pframe}
\begin{frame}
\frametitle{Committing moves \bt{HEAD} and the current branch}
\subsection{Committing moves \lstinline{HEAD} and the current branch}
\begin{pframe}
\begin{itemize}
\item Committing moves the current branch to the new commit.
\item Of course, \bt{HEAD} moves with it.
\item (In detached head state, only \bt{HEAD} moves.)
\item Of course, \lstinline{HEAD} moves with it.
\item (In detached head state, only \lstinline{HEAD} moves.)
\end{itemize}
\vspace{1cm}
\includegraphics[width=10cm]{images/commit}
\end{frame}
\bigskip
\includegraphics[width=10cm]{commit}
\end{pframe}
\subsection{A non-linear history}
\begin{pframe}
\includegraphics[width=10cm]{nonlinear}
\smallskip
\begin{frame}
\frametitle{A non-linear history}
\includegraphics[width=10cm]{images/nonlinear}
\begin{itemize}
\item The commit graph can become non-linear.
\item Usually by committing from the same commit twice.
\end{itemize}
\end{frame}
\end{pframe}
\begin{frame}
\frametitle{Use branches to keep track of different code paths}
\subsection{Use branches to keep track of different code paths}
\begin{pframe}
\begin{itemize}
\item Branch names are easier to remember than commit hashes.
\item Branch names make it clear what commits are about.
\end{itemize}
\vspace{0.5cm}
\includegraphics[width=6cm]{images/branches}
\end{frame}
\bigskip
\begin{frame}
\frametitle{Different code paths may later join}
\includegraphics[width=6cm]{branches}
\end{pframe}
\subsection{Different code paths may later join}
\begin{pframe}
\begin{itemize}
\item Commits from different branches can be brought together.
\item We call this {\em merging}.
\end{itemize}
\vspace{0.5cm}
\includegraphics[width=6cm]{images/merge}
\end{frame}
\bigskip
\includegraphics[width=6cm]{merge}
\end{pframe}
\section{Inspecting the commit graph}
\subsection{An example repository}
\begin{pframe}
\includegraphics[width=8cm]{example}
\smallskip
\begin{frame}
\frametitle{An example repository}
\includegraphics[width=8cm]{images/example}
\begin{itemize}
\item Branches \bt{license} and \bt{interface} diverged from \bt{master}.
\item Only \bt{license} has been merged back into \bt{master}.
\item Current branch is \bt{master}.
\item Branches \lstinline{license} and \lstinline{interface} diverged from
\lstinline{master}.
\item Only \lstinline{license} has been merged back into
\lstinline{master}.
\item Current branch is \lstinline{master}.
\end{itemize}
\end{frame}
\end{pframe}
\begin{frame}[fragile]
\frametitle{Showing the current branch: \bt{git status}}
\subsection{Showing the current branch: \lstinline{git status}}
\begin{pframe}
\begin{lstlisting}
$ git status
# On branch master
nothing to commit (working directory clean)
\end{lstlisting}
\bigskip
Remember: you cannot type \bt{git status} enough!
\end{frame}
\begin{frame}[fragile]
\frametitle{Listing branches: \bt{git branch}}
Remember: you cannot type \lstinline{git status} enough!
\end{pframe}