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

3 4
\usepackage[hidelinks]{hyperref}

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
5
\providecommand{\handoutsTitle}{Git Basics}
6

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
7 8
\usepackage{handouts}
\input{../shared/shared}
9

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
10 11
\begin{document}
\makeHeader
12

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
\subsubsection*{Connect to the education server}

Open \url{http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html} in your browser.
\medskip 

Download and run \href{https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe}{\textbf{putty.exe}. (Alternative binary files, the SSH and Telnet client itself)}.
\medskip

Introduce the education server IP address \textbf{145.88.35.11} as destination.
\medskip

Make sure that the \textbf{port number} is set to \textbf{22} and that \textbf{SSH} is selected as \textbf{connection type} and press ``\textbf{Open}'' to start the connection.
\medskip

Press ``Yes'' if the security alert pops up.
\medskip

Introduce your provided \textbf{username} and press enter.
\medskip

Introduce your provided \textbf{password} and press enter.
\medskip

\subsubsection*{Local configuration}
First, let Git know what your name and e-mail address is:
\begin{lstlisting}
  $ git config --global user.name "Your Name"
  $ git config --global user.email "your@email.address"
  $ cat ~/.gitconfig
\end{lstlisting}
\bigskip

It is convenient to have a \lstinline{projects} folder for your repositories:
\begin{lstlisting}
  mkdir ~/projects
  cd ~/projects
\end{lstlisting}

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
51 52
\subsubsection*{Create a repository}
First, create an empty directory and use ``\lstinline{git init}'' to make a new
53 54
repository.
\begin{itemize}
Martijn Vermaat's avatar
Martijn Vermaat committed
55 56
  \item \emph{Hint:} Use a unique name for the directory, different from your
    neighbour (this is convenient later).
57 58 59 60 61 62 63 64
  \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

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
65
\subsubsection*{Your first commit}
66
Create a new file named ``README'' (with an editor, or by using the
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
67
``\lstinline{touch}'' command).
68 69 70 71 72
\begin{itemize}
  \item \emph{Question:} What is the status of this new file?
\end{itemize}
\bigskip

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
73
Stage this file for the next commit using ``\lstinline{git add}''.
74 75 76 77 78 79 80 81 82 83 84
\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

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
85
\subsubsection*{Manipulation in the staging area}
86 87 88 89 90 91
Edit your file and stage it.
\bigskip

Now remove the file from the staging area.
\bigskip

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
92
\subsubsection*{Working with versions}
93 94 95 96 97
Commit your changed file.
\bigskip

Now you change your mind, and want to revert this commit.
\begin{itemize}
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
98
  \item \emph{Hint:} Use ``\lstinline{git log}'' to see a list of all your
99 100 101 102 103 104 105 106 107 108 109
    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.
Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
110

111
\end{document}