basics_handouts.tex 1.69 KB
Newer Older
1 2
\documentclass{article}

3
\providecommand{\handoutsTitle}{Git Basics}
4

5 6
\usepackage{handouts}
\input{../shared/shared}
7

8 9
\begin{document}
\makeHeader
10

11 12
\subsubsection*{Create a repository}
First, create an empty directory and use ``\lstinline{git init}'' to make a new
13 14
repository.
\begin{itemize}
Martijn Vermaat's avatar
Martijn Vermaat committed
15 16
  \item \emph{Hint:} Use a unique name for the directory, different from your
    neighbour (this is convenient later).
17 18 19 20 21 22 23 24
  \item \emph{Question:} How can you see that you are working in a Git
    repository?
\end{itemize}
\bigskip

Check the status of your files.
\bigskip

25
\subsubsection*{Your first commit}
26
Create a new file named ``README'' (with an editor, or by using the
27
``\lstinline{touch}'' command).
28 29 30 31 32
\begin{itemize}
  \item \emph{Question:} What is the status of this new file?
\end{itemize}
\bigskip

33
Stage this file for the next commit using ``\lstinline{git add}''.
34 35 36 37 38 39 40 41 42 43 44
\begin{itemize}
  \item \emph{Question:} What is the status of this file now?
\end{itemize}
\bigskip

Commit your changes.
\begin{itemize}
  \item \emph{Question:} What happened to the status?
\end{itemize}
\bigskip

45
\subsubsection*{Manipulation in the staging area}
46 47 48 49 50 51
Edit your file and stage it.
\bigskip

Now remove the file from the staging area.
\bigskip

52
\subsubsection*{Working with versions}
53 54 55 56 57
Commit your changed file.
\bigskip

Now you change your mind, and want to revert this commit.
\begin{itemize}
58
  \item \emph{Hint:} Use ``\lstinline{git log}'' to see a list of all your
59 60 61 62 63 64 65 66 67 68 69
    versions.
\end{itemize}
\bigskip

Edit your file again and check the differences with your last commit.
\begin{itemize}
  \item \emph{Question:} What is the difference with your first commit?
\end{itemize}
\bigskip

Make a file that you do not want to track.
70

71
\end{document}