Commit a3abe0e0 authored by Jeroen F.J. Laros's avatar Jeroen F.J. Laros

A first version of the ``basics'' lecture.

parent f2ea2965
*.pdf
*.swp
\documentclass[slidestop]{beamer}
\title{Introduction to Version Control}
\title{Git Basics}
\providecommand{\myConference}{Git course}
\providecommand{\myDate}{Monday, October 14, 2013}
\author{Jeroen F. J. Laros}
......@@ -30,14 +30,256 @@
\bodytemplate
% First page of the presentation.
\section{Introduction}
\section{Initialisation}
\begin{frame}[fragile]
\frametitle{Starting a project.}
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.]
$ git init
Initialized empty Git repository in <path>/.git/
\end{lstlisting}
\bigskip
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.}
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}
\section{Manipulation}
\begin{frame}
\frametitle{}
\frametitle{Local operations.}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.8\textheight]{pics/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.}
\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:
\begin{itemize}
\item Untracked.
\item Unmodified.
\item Modified.
\item Staged.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Checking the status of your files.}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.8\textheight]{pics/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.}
\begin{lstlisting}[language=none, caption=This file is not tracked.]
$ echo First version. > README
$ git status
# Untracked files:
# README
\end{lstlisting}
\bigskip
\begin{lstlisting}[language=none, caption=Now the file will be tracked.]
$ git add README
$ git status
# 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}
\section{Working with versions}
\begin{frame}[fragile]
\frametitle{commit}
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}
This will open an editor, give a short description of the changes you made.
\begin{itemize}
\item This is useful when you want to search for older versions later.
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Undoing changes.}
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
$ git status
# Changes to be committed:
# modified: README
\end{lstlisting}
\bigskip
If you want to undo this, you can use ``\bt{git reset}''.
\bigskip
\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{Viewing the history.}
To see the history of your project, use ``\bt{git log}''.
\bigskip
\begin{lstlisting}[language=none, caption=The log of our project.]
$ git add README
$ git commit
$ git log
commit cc61ee7cd72590f3bebcc9e1ff3e9435c7f7dd28
Author: J.F.J. Laros <j.f.j.laros@lumc.nl>
Date: Fri Oct 11 14:18:13 2013 +0200
Second version.
commit 8e10be812fd78f69a5e3bac7670c62438161b6b0
Author: J.F.J. Laros <j.f.j.laros@lumc.nl>
Date: Fri Oct 11 14:17:51 2013 +0200
First version.
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Undo a commit.}
Sometimes we want to undo an entire commit. This is done with
``\bt{git revert}''.
\bigskip
\begin{lstlisting}[language=none, caption=Revert a commit.]
$ git revert cc61ee7cd72590f3bebcc9e1ff3e9435c7f7dd28
$ cat README
First version.
\end{lstlisting}
\bigskip
The hash can be found with ``\bt{git log}''.
\end{frame}
\begin{frame}[fragile]
\frametitle{Viewing changes in detail.}
If you want to see what has changed, use ``\bt{git diff}''.
\bigskip
\begin{lstlisting}[language=none, caption=Difference between the working copy
and the last commit.]
$ echo Third version. > README
$ git diff
--- a/README
+++ b/README
@@ -1 +1 @@
-First version.
+Third version.
\end{lstlisting}
\bigskip
\end{frame}
\begin{frame}[fragile]
\frametitle{Viewing changes in detail.}
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
--- a/README
+++ b/README
@@ -1 +1 @@
-Second version.
+Third version.
\end{lstlisting}
\bigskip
\end{frame}
\section{Extras}
\begin{frame}[fragile]
\frametitle{Explicit no tracking.}
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 Files containing passwords.
\end{itemize}
\bigskip
\begin{lstlisting}[language=none, caption=Ignoring certain files.]
$ touch notrack.txt
$ echo notrack.txt > .gitignore
$ git add .gitignore
$ git commit
$ git status
nothing to commit, working directory clean
\end{lstlisting}
\end{frame}
\section{Questions?}
\lastpagetemplate
\begin{frame}
\begin{fframe}
\begin{center}
Acknowledgements:
\bigskip
......@@ -48,6 +290,9 @@
Zuotian Tatum
\end{center}
\end{frame}
\vfill
\permfoot{http://git-scm.com/book}
\end{fframe}
\end{document}
../pics/
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment