basics_handouts.tex 5.04 KB
 Jeroen F.J. Laros committed Oct 11, 2013 1 2 \documentclass{article}  Mihai committed Sep 05, 2017 3 4 \usepackage[hidelinks]{hyperref}  Jeroen F.J. Laros committed Apr 24, 2016 5 \providecommand{\handoutsTitle}{Git Basics}  Jeroen F.J. Laros committed Oct 11, 2013 6   Mihai committed Mar 28, 2018 7 8 9 10 \usepackage{multicol} \usepackage{enumitem} \usepackage{xcolor} \usepackage{graphicx}  Jeroen F.J. Laros committed Apr 24, 2016 11 \usepackage{handouts}  Mihai committed Mar 28, 2018 12   Jeroen F.J. Laros committed Apr 24, 2016 13 \input{../shared/shared}  Jeroen F.J. Laros committed Oct 11, 2013 14   Mihai committed Mar 28, 2018 15 16   Jeroen F.J. Laros committed Apr 24, 2016 17 18 \begin{document} \makeHeader  Jeroen F.J. Laros committed Oct 11, 2013 19   Mihai committed Sep 05, 2017 20 21 \subsubsection*{Connect to the education server}  Mihai committed Dec 06, 2018 22 23 Open \url{http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html} in your browser. It may be faster to google for putty.  Mihai committed Mar 28, 2018 24 \medskip  Mihai committed Sep 05, 2017 25   Mihai committed Mar 14, 2019 26 27 28 Download and run \href{https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe}{\textbf{putty.exe}}, the standalone executable and not the installer (Alternative binary files, the SSH and Telnet client itself).  Mihai committed Sep 05, 2017 29 30 31 32 33 \medskip Introduce the education server IP address \textbf{145.88.35.11} as destination. \medskip  Mihai committed Dec 06, 2018 34 35 36 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.  Mihai committed Sep 05, 2017 37 38 39 40 41 42 43 44 45 46 47 \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  Mihai committed Mar 28, 2018 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 \section{General questions} \begin{enumerate} \item How can you check your local git repository state? \vspace{-0.2cm} \begin{multicols}{3} \begin{enumerate}[label=(\alph*)] \item git state \item git repository \item git commit \item git status \item git show \item git log \end{enumerate} \end{multicols} \vspace{-0.3cm} \item What command is used to stage a file? \vspace{-0.2cm} \begin{multicols}{3} \begin{enumerate}[label=(\alph*)] \item git stage \item git checkout \item git add \item git status \item git diff \item git log \end{enumerate} \end{multicols} \vspace{-0.3cm} \item How do you tell git what files to ignore? \vspace{-0.2cm} \begin{multicols}{2} \begin{enumerate}[label=(\alph*)] \item git ignore \{file-name\} \item add the file paths to a file named .gitignore'' \item it is not possible \item git not track \{file-name\} \end{enumerate} \end{multicols} \vspace{-0.3cm} \item The \gitcmd\ \cmd{commit}\ command: \vspace{-0.2cm} \begin{multicols}{2} \begin{enumerate}[label=(\alph*)] \item stages all the modified files \item saves the staged files changes into the repository database'' \item retrieves old files into the working directory \item shows a repository history and lets the user pick what commits to discard \end{enumerate} \end{multicols} \vspace{-0.3cm} \item A file is brought into the modified state when: \vspace{-0.2cm} \begin{multicols}{2} \begin{enumerate}  Mihai committed Sep 12, 2018 107 108  \item[[ ]] it is staged \item[[ ]] it has been edited by the user  Mihai committed Mar 28, 2018 109 110 111 112 113 114 115 116 117  \item[[ ]] the user checks out a previous version of it \item[[ ]] the file is committed \end{enumerate} \end{multicols} \vspace{-0.3cm} \end{enumerate} \section{Practical exercises}  Mihai committed Sep 05, 2017 118 119 \subsubsection*{Local configuration} First, let Git know what your name and e-mail address is:  Mihai committed Dec 06, 2018 120 121 122 123 124 \medskip \prompt\ \gitcmd\ \cmd{config} \cmdopt{--global user.name "Your Name"}\\ \prompt\ \gitcmd\ \cmd{config} \cmdopt{--global user.email "your@email.address"}\\ \prompt\ \cmd{cat} $\sim$\cmdopt{/.gitconfig}  Mihai committed Sep 05, 2017 125 126 \bigskip  Jeroen F.J. Laros committed Apr 24, 2016 127 \subsubsection*{Create a repository}  Mihai committed Dec 06, 2018 128 129 First, create an empty directory inside your home directory and use \gitcmd\ \cmd{init}'' in that  bow committed Nov 17, 2017 130 newly-created directory to make a new repository.  Jeroen F.J. Laros committed Oct 11, 2013 131 \begin{itemize}  bow committed Nov 17, 2017 132  \item \emph{Hint:} Use a short and descriptive name for the directory.  Jeroen F.J. Laros committed Oct 11, 2013 133 134 135 136 137  \item \emph{Question:} How can you see that you are working in a Git repository? \end{itemize} \bigskip  Mihai committed Nov 21, 2017 138 Check the status of your repository.  Jeroen F.J. Laros committed Oct 11, 2013 139   Jeroen F.J. Laros committed Apr 24, 2016 140 \subsubsection*{Your first commit}  Jeroen F.J. Laros committed Oct 11, 2013 141 Create a new file named README'' (with an editor, or by using the  Mihai committed Dec 06, 2018 142 \cmd{touch}'' command).  Jeroen F.J. Laros committed Oct 11, 2013 143 144 145 \begin{itemize} \item \emph{Question:} What is the status of this new file? \end{itemize}  Mihai committed Mar 14, 2019 146 \medskip  Jeroen F.J. Laros committed Oct 11, 2013 147   Mihai committed Dec 06, 2018 148 Stage this file for the next commit using \gitcmd\ \cmd{add}''.  Jeroen F.J. Laros committed Oct 11, 2013 149 150 151 \begin{itemize} \item \emph{Question:} What is the status of this file now? \end{itemize}  Mihai committed Mar 14, 2019 152 \medskip  Jeroen F.J. Laros committed Oct 11, 2013 153 154 155 156 157 158  Commit your changes. \begin{itemize} \item \emph{Question:} What happened to the status? \end{itemize}  Jeroen F.J. Laros committed Apr 24, 2016 159 \subsubsection*{Manipulation in the staging area}  Mihai committed Mar 14, 2019 160 161 Edit your file. Check the repository status. \medskip  Jeroen F.J. Laros committed Oct 11, 2013 162   Mihai committed Mar 14, 2019 163 164 Stage your modified file. Check the repository status. \medskip  Jeroen F.J. Laros committed Oct 11, 2013 165   Mihai committed Mar 14, 2019 166 167 168 169 170 171 172 Now remove the file from the staging area. Check the repository status. \medskip Discard the changes performed to the file. Check the repository status. \medskip Edit again the file, stage it, and commit.  Mihai committed Dec 06, 2018 173   Jeroen F.J. Laros committed Apr 24, 2016 174 \subsubsection*{Working with versions}  Mihai committed Mar 14, 2019 175 Edit your file again and commit one more time.  Jeroen F.J. Laros committed Oct 11, 2013 176 177 \bigskip  Mihai committed Dec 06, 2018 178 179 Now you change your mind and you want to restore the version stored in the previous commit.  Jeroen F.J. Laros committed Oct 11, 2013 180 \begin{itemize}  Mihai committed Dec 06, 2018 181  \item \emph{Hint:} Use \gitcmd\ \cmd{log}'' to see a list of all your  Jeroen F.J. Laros committed Oct 11, 2013 182 183 184 185 186 187 188 189 190 191 192  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 committed Apr 24, 2016 193   Jeroen F.J. Laros committed Oct 11, 2013 194 \end{document}