-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_basics.tex
388 lines (315 loc) · 16 KB
/
git_basics.tex
1
2
3
4
5
6
7
8
9
10
11
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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
\documentclass{beamer}
\title{Git Basics}
\author{David Kouka}
\date{\today}
\usepackage{tikz}
\usetikzlibrary{automata}
\usetikzlibrary{arrows.meta, positioning, calc, shapes.geometric}
\usepackage{graphicx} % For including images
\usepackage{listings} % For code listings
\lstset{
basicstyle=\ttfamily\color{blue}, % Change color and font
keywordstyle=\color{red},
commentstyle=\color{green},
stringstyle=\color{orange},
columns=flexible,
keepspaces=true,
showstringspaces=false,
}
\begin{document}
\frame{\titlepage}
\begin{frame}
\frame{Table of Contents}
\tableofcontents
\end{frame}
\section{Version control}
\begin{frame}{Why using version control}
\begin{itemize}
\item<1-> Tracking changes \lstinline{git diff} \includegraphics[width=0.07\linewidth]{img/register.png}
\item<2-> Backup and recovery \lstinline{git checkout} \includegraphics[width=0.08\linewidth]{img/time_machine.png}
\item<3-> Collaborative work (authors, conflicts, PR) \includegraphics[width=0.07\linewidth]{img/collaborate.png}
\item<4-> Accountability \lstinline{git blame}\includegraphics[width=0.09\linewidth]{img/blame.png}
\item<5-> "Documentation" via commit messages \lstinline{git log}\includegraphics[width=0.07\linewidth]{img/doc.png}
\item<6-> Safe experiments \lstinline{git branch} \includegraphics[width=0.07\linewidth]{img/experiments.png}
\item<7-> Easy release management (tags, banches, CI/CD, ...) \includegraphics[width=0.07\linewidth]{img/devops.png}
\end{itemize}
\end{frame}
\section{Hosting}
\begin{frame}{Hosting}
\only<1-> Git hosting platforms
\begin{itemize}
\item<2-> Bitbucket \includegraphics[width=0.07\linewidth]{img/logo_bitbucket.png}
\item<3-> Gitea \includegraphics[width=0.07\linewidth]{img/logo_gitea.png}
\item<4-> Github \includegraphics[width=0.07\linewidth]{img/logo_github.png}
\item<5-> Gitlab \includegraphics[width=0.07\linewidth]{img/logo_gitlab.png}
\end{itemize}
\end{frame}
\section{Cloning}
\begin{frame}{git clone}
\centering
\begin{tikzpicture}[
node distance=2cm,
image node/.style={inner sep=0, outer sep=0}
]
\only<1>{
\node[image node] (laptop) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, right=4cm of laptop] (server) {\includegraphics[width=1.5cm]{img/server.png}};
\node[image node, below=1cm of server] (potato1_server) {\includegraphics[width=1cm]{img/potato_1.png}};
}
\only<2>{
\node[image node] (laptop) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, right=4cm of laptop] (server) {\includegraphics[width=1.5cm]{img/server.png}};
\node[image node, below=1cm of server] (potato1_server) {\includegraphics[width=1cm]{img/potato_1.png}};
\node[image node, below=1cm of laptop] (potato1_laptop) {\includegraphics[width=1cm]{img/potato_1.png}};
\draw[->, thick] (potato1_server) -- node[above] {git clone} (potato1_laptop);
}
\end{tikzpicture}
\end{frame}
\section{Stage/Commit/Push}
\begin{frame}{Modifications}
\centering
\includegraphics[width=0.5\linewidth]{img/potato_1.png}
\end{frame}
\begin{frame}{Modifications}
\centering
\includegraphics[width=0.5\linewidth]{img/potato_2.png}
\end{frame}
\begin{frame}{git add}
\centering
\includegraphics[width=0.5\linewidth]{img/git_add.png}
\end{frame}
\begin{frame}{git commit}
\centering
\includegraphics[width=0.4\linewidth]{img/commit.png}
\end{frame}
\begin{frame}{git push}
\centering
\begin{tikzpicture}[
node distance=2cm,
image node/.style={inner sep=0, outer sep=0}
]
\only<1>{
\node[image node] (laptop) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, below=1cm of laptop] (potato2_laptop) {\includegraphics[width=1cm]{img/potato_2.png}};
\node[image node, right=4cm of laptop] (server) {\includegraphics[width=1.5cm]{img/server.png}};
\node[image node, below=1cm of server] (potato1_server) {\includegraphics[width=1cm]{img/potato_1.png}};
}
\only<2>{
\node[image node] (laptop) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, right=4cm of laptop] (server) {\includegraphics[width=1.5cm]{img/server.png}};
\node[image node, below=1cm of server] (potato2_server) {\includegraphics[width=1cm]{img/potato_2.png}};
\node[image node, below=1cm of laptop] (potato2_laptop) {\includegraphics[width=1cm]{img/potato_2.png}};
\draw[->, thick] (potato2_laptop) -- node[above] {git push} (potato2_server);
\node[image node, right=1.4cm of laptop] (delivery) {\includegraphics[width=1.5cm]{img/delivery.png}};
}
\end{tikzpicture}
\end{frame}
\section{Pull}
\begin{frame}{git pull}
\centering
\begin{tikzpicture}[
node distance=2cm,
image node/.style={inner sep=0, outer sep=0}
]
\only<1>{
\node[image node] (laptop) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, below=1cm of laptop] (potato2_laptop) {\includegraphics[width=1cm]{img/potato_2.png}};
\node[image node, right=2cm of laptop] (server) {\includegraphics[width=1.5cm]{img/server.png}};
\node[image node, below=1cm of server] (potato2_server) {\includegraphics[width=1cm]{img/potato_2.png}};
\node[image node, right=2cm of server] (laptop2) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, below=1cm of laptop2] (potato1_laptop2) {\includegraphics[width=1cm]{img/potato_1.png}};
}
\only<2>{
\node[image node] (laptop) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, below=1cm of laptop] (potato2_laptop) {\includegraphics[width=1cm]{img/potato_2.png}};
\node[image node, right=2cm of laptop] (server) {\includegraphics[width=1.5cm]{img/server.png}};
\node[image node, below=1cm of server] (potato2_server) {\includegraphics[width=1cm]{img/potato_2.png}};
\node[image node, right=2cm of server] (laptop2) {\includegraphics[width=1.5cm]{img/laptop.png}};
\node[image node, below=1cm of laptop2] (potato2_laptop2) {\includegraphics[width=1cm]{img/potato_2.png}};
\draw[->, thick] (potato2_server) -- node[above] {git pull} (potato2_laptop2);
}
\end{tikzpicture}
\end{frame}
\section{Branches}
\begin{frame}{git branch}
\begin{tikzpicture}[
node/.style={circle, draw=black, very thick, minimum size=15mm},
img/.style={minimum size=15mm}
]
\node[node] (main) {main};
\node[img] (img1) [right=of main] {\includegraphics[width=15mm]{img/bunshin.png}};
\pause
\node[node] (rasengan) [below left=of main] {\small rasengan};
\node[img] (img2) [left=of rasengan] {\includegraphics[width=15mm]{img/bunshin.png}};
\node[node] (senin) [below right=of main] {senin};
\node[img] (img3) [right=of senin] {\includegraphics[width=15mm]{img/bunshin.png}};
\draw[->] (main) -- (rasengan) node[midway, left] {\texttt{git branch rasengan}};
\draw[->] (main) -- (senin) node[midway, right] {\texttt{git branch senin}};
\end{tikzpicture}
\end{frame}
\begin{frame}{git branch}
\begin{tikzpicture}[
node/.style={circle, draw=black, very thick, minimum size=15mm},
img/.style={minimum size=15mm}
]
\node[node] (main) {main};
\node[img] (img1) [right=of main] {\includegraphics[width=15mm]{img/bunshin.png}};
\node[node] (rasengan) [below left=of main] {\small rasengan};
\node[img] (img2) [left=of rasengan] {\includegraphics[width=15mm]{img/rasengan.png}};
\node[node] (senin) [below right=of main] {senin};
\node[img] (img3) [right=of senin] {\includegraphics[width=15mm]{img/sage.png}};
\draw[->] (main) -- (rasengan) node[midway, left] {\texttt{git branch rasengan}};
\draw[->] (main) -- (senin) node[midway, right] {\texttt{git branch senin}};
\end{tikzpicture}
\end{frame}
\section{Merge}
\begin{frame}{git merge}
\begin{tikzpicture}[
node/.style={circle, draw=black, very thick, minimum size=15mm},
img/.style={minimum size=15mm}
]
\node[node] (main) {main};
\node[img] (img1) [right=of main] {\includegraphics[width=15mm]{img/bunshin.png}};
\node[node] (rasengan) [below left=of main] {\small rasengan};
\node[img] (img2) [left=of rasengan] {\includegraphics[width=15mm]{img/rasengan.png}};
\node[node] (senin) [below right=of main] {senin};
\node[img] (img3) [right=of senin] {\includegraphics[width=15mm]{img/sage.png}};
\draw[->] (main) -- (rasengan) node[midway, left] {\texttt{git branch rasengan}};
\draw[->] (main) -- (senin) node[midway, right] {\texttt{git branch senin}};
\node[node] (merge) [below=of $(rasengan.south)!0.5!(senin.south)$] {merge};
\node[img] (img4) [right=of merge] {\includegraphics[width=15mm]{img/naruto_sage_rasengan.png}};
\draw[->] (rasengan) -- (merge) node[midway, left] {\texttt{git merge}};
\draw[->] (senin) -- (merge) node[midway, right] {\texttt{git merge}};
\end{tikzpicture}
\end{frame}
\section{Conflicts}
\begin{frame}{conflicts}
\begin{tikzpicture}[
node/.style={circle, draw=black, very thick, minimum size=5mm},
img/.style={minimum size=7mm}
]
\node[node] (main) {};
\pause
\node[node] (udon_left) [below left=of main] {};
\node[img] (img1) [left=of udon_left] {\includegraphics[width=7mm]{img/udon.png}};
\node[node] (udon_right) [below right=of main] {};
\node[img] (img2) [right=of udon_right] {\includegraphics[width=7mm]{img/udon.png}};
\draw[->] (main) -- (udon_left) node[midway, left] {};
\draw[->] (main) -- (udon_right) node[midway, right] {};
\pause
\node[node] (eggs_left) [below=of udon_left] {};
\node[img] (img3) [left=of eggs_left] {\includegraphics[width=7mm]{img/eggs.png}};
\node[node] (eggs_right) [below=of udon_right] {};
\node[img] (img4) [right=of eggs_right] {\includegraphics[width=7mm]{img/eggs.png}};
\draw[->] (udon_left) -- (eggs_left) node[midway, below] {};
\draw[->] (udon_right) -- (eggs_right) node[midway, below] {};
\pause
\node[node, fill=red] (soy_left) [below=of eggs_left] {};
\node[img] (img5) [left=of soy_left] {\includegraphics[width=7mm]{img/soy_sauce.png}};
\node[node, fill=blue] (garlic_right) [below=of eggs_right] {};
\node[img] (img5) [right=of garlic_right] {\includegraphics[width=7mm]{img/garlic.png}};
\draw[->] (eggs_left) -- (soy_left) node[midway, below] {};
\draw[->] (eggs_right) -- (garlic_right) node[midway, below] {};
\pause
\node[node] (ramen_left) [below=of soy_left] {};
\node[img] (img5) [left=of ramen_left] {\includegraphics[width=7mm]{img/ramen.png}};
\node[node] (ramen_right) [below=of garlic_right] {};
\node[img] (img6) [right=of ramen_right] {\includegraphics[width=7mm]{img/ramen.png}};
\draw[->] (soy_left) -- (ramen_left) node[midway, below] {};
\draw[->] (garlic_right) -- (ramen_right) node[midway, below] {};
\pause
\node[node, minimum size = 3mm] (merge) [below=of $(ramen_left.south)!0.5!(ramen_right.south)$] {\small x};
\draw[->] (ramen_left) -- (merge) node[midway, left] {\texttt{???}};
\draw[->] (ramen_right) -- (merge) node[midway, right] {\texttt{???}};
\end{tikzpicture}
\end{frame}
\begin{frame}{First commit}
\begin{tikzpicture}[
node/.style={circle, draw=black, very thick, minimum size=5mm},
img/.style={minimum size=7mm}
]
\node[node] (main) {\small main};
\pause
\node[node] (udon_left) [below left=of main] {};
\node[img] (img1) [left=of udon_left] {\includegraphics[width=7mm]{img/udon.png}};
\draw[->] (main) -- (udon_left) node[midway, left] {};
\node[node] (eggs_left) [below=of udon_left] {};
\node[img] (img3) [left=of eggs_left] {\includegraphics[width=7mm]{img/eggs.png}};
\draw[->] (udon_left) -- (eggs_left) node[midway, below] {};
\node[node, fill=red] (soy_left) [below=of eggs_left] {};
\node[img] (img5) [left=of soy_left] {\includegraphics[width=7mm]{img/soy_sauce.png}};
\draw[->] (eggs_left) -- (soy_left) node[midway, below] {};
\node[node] (ramen_left) [below=of soy_left] {};
\node[img] (img5) [left=of ramen_left] {\includegraphics[width=7mm]{img/ramen.png}};
\draw[->] (soy_left) -- (ramen_left) node[midway, below] {};
\node[node] (merge) [below right=of ramen_left] {\small main};
\draw[->] (ramen_left) -- (merge) node[midway, left] {\texttt{git merge}};
\end{tikzpicture}
\end{frame}
\begin{frame}{2nd commit conflict}
\begin{tikzpicture}[
node/.style={circle, draw=black, very thick, minimum size=5mm},
img/.style={minimum size=7mm}
]
\node[node] (main) {};
\node[node] (udon_right) [below right=of main] {};
\node[img] (img2) [right=of udon_right] {\includegraphics[width=7mm]{img/udon.png}};
\draw[->] (main) -- (udon_right) node[midway, right] {};
\node[node] (eggs_right) [below=of udon_right] {};
\node[img] (img4) [right=of eggs_right] {\includegraphics[width=7mm]{img/eggs.png}};
\draw[->] (udon_right) -- (eggs_right) node[midway, below] {};
\node[node, fill=blue] (garlic_right) [below=of eggs_right] {};
\node[img] (img5) [right=of garlic_right] {\includegraphics[width=7mm]{img/garlic.png}};
\draw[->] (eggs_right) -- (garlic_right) node[midway, below] {};
\node[node] (ramen_right) [below=of garlic_right] {};
\node[img] (img6) [right=of ramen_right] {\includegraphics[width=7mm]{img/ramen.png}};
\draw[->] (garlic_right) -- (ramen_right) node[midway, below] {};
\node[node, minimum size = 3mm] (merge) [below left=of ramen_right] {\small x};
\draw[->] (ramen_right) -- (merge) node[midway, right] {\texttt{???}};
\end{tikzpicture}
\end{frame}
\begin{frame}{Resolving Conflicts}
\centering
\begin{tikzpicture}[
node/.style={circle, draw=black, very thick, minimum size=5mm},
img/.style={minimum size=7mm}
]
\node[node, diamond] (merge) {merge?};
\pause
\node[node, below left=of merge, label=below:Incoming, fill=red] (incoming) {};
\node[img] (img1) [left=of incoming] {\includegraphics[width=1.5cm]{img/soy_sauce.png}};
\draw[->] (merge) -- (incoming);
\pause
\node[node, below=of merge, label=below:Current, fill=blue] (current) {};
\node[img] (img2) [below=of current] {\includegraphics[width=1.1cm]{img/garlic.png}};
\draw[->] (merge) -- (current);
\pause
\node[node, below right=of merge, label=below:Both, fill=purple] (both) {};
\node[img] (img3) [right=of both] {\includegraphics[width=1.5cm]{img/soy_sauce.png}};
\node[img] (img4) [right=of img3] {\includegraphics[width=1.1cm]{img/garlic.png}};
\draw[->] (merge) -- (both);
\end{tikzpicture}
\end{frame}
\section{Getting further}
\begin{frame}{Getting further}
\begin{itemize}
\item<1-> \lstinline{git status}
\item<2-> submodules
\item<3-> signed commits
\item<4-> \href{https://education.github.com/git-cheat-sheet-education.pdf}{Cheat Sheet}
\end{itemize}
\end{frame}
\section{Questions}
\begin{frame}{Questions ?}
\centering
\includegraphics[width=0.7\linewidth]{img/naruto_ramen.png}
\end{frame}
\section{Credits}
\begin{frame}{Credits}
\begin{itemize}
\item flaticon.com authors: Freepik, Flat Icons, ultimatearm, Wahyu.Setyanto, iconixar
\item pngwing.com
\item pngegg.com
\end{itemize}
\end{frame}
\end{document}