basics_handouts.tex 2.92 KB
Newer Older
Laros's avatar
Laros committed
1 2
\documentclass{article}

3 4
\usepackage[hidelinks]{hyperref}

Laros's avatar
Laros committed
5
\providecommand{\handoutsTitle}{Git Basics}
Laros's avatar
Laros committed
6

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

Laros's avatar
Laros committed
10 11
\begin{document}
\makeHeader
Laros's avatar
Laros committed
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}

Laros's avatar
Laros committed
51
\subsubsection*{Create a repository}
52 53
First, create an empty directory inside ``lstinline{~/projects}`` and use ``\lstinline{git init}'' in that
newly-created directory to make a new repository.
Laros's avatar
Laros committed
54
\begin{itemize}
55
  \item \emph{Hint:} Use a short and descriptive name for the directory.
Laros's avatar
Laros committed
56 57 58 59 60 61 62 63
  \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

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

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

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

Now remove the file from the staging area.
\bigskip

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

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

Laros's avatar
Laros committed
110
\end{document}