You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

609 lines
14 KiB

3 years ago
  1. \year=2021
  2. \month=9
  3. \day=14
  4. \documentclass[aspectratio=1610,xcolor=dvipsnames]{beamer}
  5. \usepackage{pgfplots}
  6. \pgfplotsset{compat=1.17}
  7. \usepackage{fontspec}
  8. \usepackage{polyglossia}
  9. \setdefaultlanguage{german}
  10. \usepackage[font=scriptsize]{caption}
  11. \usepackage{fontawesome}
  12. \usepackage{graphicx}
  13. \usepackage{tikzfig}
  14. \usetikzlibrary{positioning}
  15. \graphicspath{{./figures/}}
  16. \usepackage{csquotes}
  17. \usepackage{fancyvrb}
  18. \usepackage[
  19. backend=biber,
  20. style=verbose-ibid,
  21. block=ragged,
  22. ]{biblatex}
  23. \addbibresource{presi.bib}
  24. \usecolortheme{seahorse}
  25. \setbeamerfont{footnote}{size=\tiny}
  26. \usepackage{minted}
  27. \usemintedstyle{friendly}
  28. \setminted{
  29. baselinestretch=1,
  30. breaklines=true,
  31. autogobble=true,
  32. bgcolor=lightgray!50,
  33. }
  34. \newmintinline[x]{console}{}
  35. \colorlet{bgl}{cyan!50!lightgray!50}
  36. \colorlet{bgr}{orange!50!lightgray!50}
  37. \title{Git SCM}
  38. \subtitle{Crash-Course in Versionsverwaltung and kolaborativem bearbeiten von Textdateien}
  39. \author{Dustin Frisch\\
  40. Fachbereich Angewandte Informatik\\
  41. Hochschule Fulda\\
  42. Fulda, Deutschland\\
  43. E-Mail: {\tt dustin.frisch@ai.hs-fulda.de}}
  44. \begin{document}
  45. \frame{\titlepage}
  46. \begin{frame}{Agenda}
  47. \tableofcontents
  48. \end{frame}
  49. \section{Was soll das alles?}
  50. \begin{frame}{Was ist Versionverwaltung?}
  51. \begin{columns}[t]
  52. \begin{column}{0.5\textwidth}
  53. \centering
  54. \large{Ohne Versionverwaltung}
  55. \begin{figure}[H]
  56. \begin{tikzpicture}[]
  57. \tikzstyle{state}+=[circle, draw=cyan!60, fill=cyan!5, very thick, minimum size=2.5em]
  58. \tikzstyle{file}+=[rectangle, draw=green!60, fill=green!5, very thick, minimum size=2.5em]
  59. \tikzstyle{update}+=[->, thick, dotted]
  60. \tikzstyle{save}+=[->, thick]
  61. \node[state](s1){+A};
  62. \node[state](s2)[right=1em of s1]{+B};
  63. \node[state](s3)[right=1em of s2]{-A};
  64. \node[state](s4)[right=1em of s3]{+C};
  65. \node[file](f) at (2,-3) {$doc$};
  66. \draw[update] (s1.east) -- (s2.west);
  67. \draw[update] (s2.east) -- (s3.west);
  68. \draw[update] (s3.east) -- (s4.west);
  69. \draw[save] (s1.south) -- ([xshift=-0.9em] f.north);
  70. \draw[save] (s2.south) -- ([xshift=-0.3em] f.north);
  71. \draw[save] (s3.south) -- ([xshift=0.3em] f.north);
  72. \draw[save] (s4.south) -- ([xshift=0.9em] f.north);
  73. \end{tikzpicture}
  74. \end{figure}
  75. \end{column}
  76. \begin{column}{0.5\textwidth}
  77. \centering
  78. \large{Mit Versionverwaltung}
  79. \begin{figure}[H]
  80. \begin{tikzpicture}[]
  81. \tikzstyle{state}+=[circle, draw=cyan!60, fill=cyan!5, very thick, minimum size=2.5em]
  82. \tikzstyle{file}+=[rectangle, draw=green!60, fill=green!5, very thick, minimum size=2.5em]
  83. \tikzstyle{update}+=[->, thick, dotted]
  84. \tikzstyle{save}+=[->, thick]
  85. \node[state](s1){+A};
  86. \node[state](s2)[right=1em of s1]{+B};
  87. \node[state](s3)[right=1em of s2]{-A};
  88. \node[state](s4)[right=1em of s3]{+C};
  89. \node[file](f1)[below=2 of s1]{$doc_1$};
  90. \node[file](f2)[below=2 of s2]{$doc_2$};
  91. \node[file](f3)[below=2 of s3]{$doc_3$};
  92. \node[file](f4)[below=2 of s4]{$doc_4$};
  93. \draw[update] (s1.east) -- (s2.west);
  94. \draw[update] (s2.east) -- (s3.west);
  95. \draw[update] (s3.east) -- (s4.west);
  96. \draw[save] (s1.south) -- (f1.north);
  97. \draw[save] (s2.south) -- (f2.north);
  98. \draw[save] (s3.south) -- (f3.north);
  99. \draw[save] (s4.south) -- (f4.north);
  100. \end{tikzpicture}
  101. \end{figure}
  102. \end{column}
  103. \end{columns}
  104. \end{frame}
  105. \begin{frame}{Wo kann ich das einsetzen?}
  106. \begin{itemize}
  107. \item Source-Code
  108. \item Konfiguration
  109. \item Dokumente
  110. \item Daten
  111. \end{itemize}
  112. \vspace{1em}
  113. Also alles, was \emph{Text} ist.
  114. \end{frame}
  115. \begin{frame}{Was bringt mir das?}
  116. \centering
  117. {
  118. \fontsize{40}{48}\selectfont
  119. Zeitmaschinen
  120. }\\
  121. \vspace{1em}
  122. \small{und}\\
  123. \vspace{1em}
  124. {
  125. \fontsize{40}{48}\selectfont
  126. Paralleluniversen
  127. }
  128. \end{frame}
  129. \section{Warum jetzt genau Git?}
  130. \begin{frame}{Kurze Histore}
  131. \begin{figure}[H]
  132. \begin{tikzpicture}[]
  133. \tikzstyle{kind}+=[rectangle, very thick, minimum size=3.5em]
  134. \tikzstyle{prod}+=[]
  135. \node[kind, draw=red!90!yellow!60, fill=red!90!yellow!5] (l) at(0,6) {Lokale Versionsverwaltung};
  136. \node[kind, draw=red!60!yellow!60, fill=red!60!yellow!5] (c) at(0,3) {Zentrale Versionsverwaltung};
  137. \node[kind, draw=red!30!yellow!60, fill=red!30!yellow!5] (d) at(0,0) {Verteilte Versionsverwaltung};
  138. \draw[->,thick] (l.south) -- (c.north);
  139. \draw[->,thick] (c.south) -- (d.north);
  140. \node[prod] (l1) [right=of l, yshift=+1em] {SCCS};
  141. \node[prod] (l2) [right=of l, yshift=-1em] {RCS};
  142. \node[prod] (c1) [right=of c, yshift=+1em] {CSV};
  143. \node[prod] (c2) [right=of c, yshift=-1em] {SVN};
  144. \node[prod] (d1) [right=of d, yshift=+1em] {Git};
  145. \node[prod] (d2) [right=of d, yshift= 0em] {Bazaar};
  146. \node[prod] (d3) [right=of d, yshift=-1em] {Mercurial};
  147. \draw[->] (l.east) -- (l1.west);
  148. \draw[->] (l.east) -- (l2.west);
  149. \draw[->] (c.east) -- (c1.west);
  150. \draw[->] (c.east) -- (c2.west);
  151. \draw[->] (d.east) -- (d1.west);
  152. \draw[->] (d.east) -- (d2.west);
  153. \draw[->] (d.east) -- (d3.west);
  154. \end{tikzpicture}
  155. \end{figure}
  156. \end{frame}
  157. \begin{frame}{Git is everywhere}
  158. \begin{columns}[c]
  159. \begin{column}{0.5\textwidth}
  160. \centering
  161. \includegraphics[width=0.9\textwidth]{logos/GitHub.png}
  162. \end{column}
  163. \begin{column}{0.5\textwidth}
  164. \centering
  165. \includegraphics[width=0.9\textwidth]{logos/Codeberg.png}
  166. \end{column}
  167. \end{columns}
  168. \vspace{1em}
  169. \begin{columns}[c]
  170. \begin{column}{0.5\textwidth}
  171. \centering
  172. \includegraphics[width=0.9\textwidth]{logos/GitLab.png}
  173. \end{column}
  174. \begin{column}{0.5\textwidth}
  175. \centering
  176. \includegraphics[width=0.9\textwidth]{logos/SourceHut.png}
  177. \end{column}
  178. \end{columns}
  179. \vspace{1em}
  180. \begin{columns}[c]
  181. \begin{column}{0.5\textwidth}
  182. \centering
  183. \includegraphics[width=0.9\textwidth]{logos/Gitea.png}
  184. \end{column}
  185. \begin{column}{0.5\textwidth}
  186. \centering
  187. \includegraphics[width=0.9\textwidth]{logos/Bitbucket.png}
  188. \end{column}
  189. \end{columns}
  190. \end{frame}
  191. \section{Einrichtung und Installation}
  192. \begin{frame}[fragile]{Installation}
  193. \begin{description}
  194. \item[Windows] https://gitforwindows.org/ oder \\
  195. \x^# choco install git^
  196. \item[Linux] \x^# sudo dnf install git-all^ oder \\
  197. \x^# sudo apt install git-all^ oder ...
  198. \item[macOS] \x^# git --version^
  199. \end{description}
  200. \end{frame}
  201. \begin{frame}[fragile]{Einrichtung}
  202. \begin{minted}{console}
  203. # git config --global user.name "Dustin Frisch"
  204. # git config --global user.email "dustin.frisch@ai.hs-fulda.de"
  205. \end{minted}
  206. \end{frame}
  207. \begin{frame}
  208. \centering
  209. \LARGE
  210. Pause
  211. \end{frame}
  212. \section{Aller Anfang ist schwer}
  213. \begin{frame}[fragile]{Neues Projekt}
  214. Neuen Ordner anlegen und in diesen wechseln.
  215. \begin{minted}{console}
  216. # git init
  217. Initialized empty Git repository in /home/fooker/tmp/myproject/.git/
  218. \end{minted}
  219. \end{frame}
  220. \begin{frame}[fragile]{Den überblick behalten}
  221. Eine Datei in dem Ordner anlegen.
  222. \begin{minted}{console}
  223. # git status
  224. On branch main
  225. No commits yet
  226. Untracked files:
  227. (use "git add <file>..." to include in what will be committed)
  228. test.c
  229. nothing added to commit but untracked files present (use "git add" to track)
  230. \end{minted}
  231. \end{frame}
  232. \begin{frame}[fragile]{Der Staging-Bereich}
  233. \begin{minted}{console}
  234. # git add test.c
  235. # git status
  236. On branch main
  237. No commits yet
  238. Changes to be committed:
  239. (use "git rm --cached <file>..." to unstage)
  240. new file: test.c
  241. \end{minted}
  242. \end{frame}
  243. \begin{frame}[fragile]{Mein erstes mal}
  244. \begin{minted}{console}
  245. # git commit
  246. main (root-commit) 27cda20] A wonderful commit message
  247. 1 file changed, 6 insertions(+)
  248. create mode 100644 test.c
  249. # git status
  250. On branch main
  251. nothing to commit, working tree clean
  252. \end{minted}
  253. \end{frame}
  254. \begin{frame}[fragile]{Oh, ein wie konnte das nur passieren}
  255. Die Datei in dem Ordner wird geändert.
  256. \begin{minted}{console}
  257. # git add test.c
  258. # git commit
  259. \end{minted}
  260. \end{frame}
  261. \begin{frame}[fragile]{Was bisher geschah...}
  262. \begin{minted}{console}
  263. # git log
  264. commit 7163f25b8e477a43accc28c30f3bd4351a2d72a2
  265. Author: Dustin Frisch <fooker@lab.sh>
  266. Date: Mon Oct 18 22:12:28 2021 +0200
  267. Fixed dumb mistake
  268. commit 27cda204ad4caae123b44f1fc8d3ac6645e66d3f
  269. Author: Dustin Frisch <fooker@lab.sh>
  270. Date: Mon Oct 18 22:07:31 2021 +0200
  271. A wonderful commit message
  272. \end{minted}
  273. \end{frame}
  274. \begin{frame}[fragile]{So langsam wird es}
  275. Eine weitere Datei anlegen.
  276. \begin{minted}{console}
  277. # git add example.c
  278. # git commit -m "Added example"
  279. \end{minted}
  280. \end{frame}
  281. \begin{frame}[fragile]{Namesgebung ist schwierig}
  282. Eine Datei umbenennen.
  283. \begin{minted}{console}
  284. # git status
  285. On branch main
  286. Changes not staged for commit:
  287. (use "git add/rm <file>..." to update what will be committed)
  288. (use "git restore <file>..." to discard changes in working directory)
  289. deleted: test.c
  290. Untracked files:
  291. (use "git add <file>..." to include in what will be committed)
  292. main.c
  293. no changes added to commit (use "git add" and/or "git commit -a")
  294. \end{minted}
  295. \end{frame}
  296. \begin{frame}[fragile]{Namensgebung ist schwierig}
  297. \begin{minted}{console}
  298. # git add test.c main.c
  299. # git status
  300. On branch main
  301. Changes to be committed:
  302. (use "git restore --staged <file>..." to unstage)
  303. renamed: test.c -> main.c
  304. # git commit -m "Naming fixed"
  305. \end{minted}
  306. \end{frame}
  307. \begin{frame}[fragile]{Und weg damit}
  308. Eine Datei löschen.
  309. \begin{minted}{console}
  310. # git rm example.c
  311. # git commit -m "This was a mistake"
  312. \end{minted}
  313. \end{frame}
  314. \begin{frame}[fragile]{Was hab ich nur getan}
  315. Eine Datei ändern.
  316. \begin{minted}{console}
  317. # git diff
  318. \end{minted}
  319. \end{frame}
  320. \begin{frame}[fragile]{Keine Fehler}
  321. \begin{minted}{console}
  322. # git restore main.c
  323. \end{minted}
  324. \end{frame}
  325. \begin{frame}[fragile]{Was werde ich nur getan haben}
  326. Eine Datei ändern.
  327. \begin{minted}{console}
  328. # git add main.c
  329. # git diff --staged
  330. \end{minted}
  331. \end{frame}
  332. \begin{frame}[fragile]{Nee, doch nicht}
  333. Datei nochmal ändern
  334. \begin{minted}{console}
  335. # git restore --staged main.c
  336. \end{minted}
  337. \end{frame}
  338. \section{Ein Baum ist ein Baum ist ein Baum}
  339. \begin{frame}[fragile]{Alles hat ein Ende}
  340. \begin{minted}{console}
  341. # git branch
  342. * main
  343. \end{minted}
  344. \end{frame}
  345. \begin{frame}[fragile]{Nur der Baum hat viele}
  346. \begin{minted}{console}
  347. # git branch feature-x
  348. # git branch
  349. feature-x
  350. * main
  351. \end{minted}
  352. \end{frame}
  353. \begin{frame}[fragile]{Wer die Wahl hat}
  354. \begin{minted}{console}
  355. # git checkout feature-x
  356. Switched to branch 'feature-x'
  357. # git branch
  358. * feature-x
  359. main
  360. \end{minted}
  361. \end{frame}
  362. \begin{frame}[fragile]{Als währe nichts gewesen}
  363. Ein paar Commits erzeugen.
  364. \begin{minted}{console}
  365. # git checkout main
  366. Switched to branch 'main'
  367. # git log
  368. ...
  369. \end{minted}
  370. \end{frame}
  371. \begin{frame}[fragile]{Realität ist subjektiv}
  372. Eine paar Commits erzeugen.
  373. \begin{minted}{console}
  374. # git checkout feature-x
  375. Switched to branch 'feature-x'
  376. # git log
  377. ...
  378. \end{minted}
  379. \end{frame}
  380. \begin{frame}[fragile]{Zusammen was zusammen gehört}
  381. \begin{minted}{console}
  382. # git merge main
  383. Merge made by the 'recursive' strategy.
  384. ...
  385. # git log
  386. ...
  387. \end{minted}
  388. \end{frame}
  389. \begin{frame}
  390. \centering
  391. \LARGE
  392. Pause
  393. \end{frame}
  394. \section{Mein, dein. Das sind doch bürgerliche Kategorien}
  395. \begin{frame}[fragile]{So klein und schon bei den Sturmtruppen?}
  396. \begin{minted}[bgcolor=bgr]{console}
  397. # git clone http://git.open-desk.net/git/_.git project
  398. \end{minted}
  399. \begin{minted}[bgcolor=bgr]{console}
  400. # git remote -v
  401. origin http://git.open-desk.net/git/_.git (fetch)
  402. origin http://git.open-desk.net/git/_.git (push)
  403. \end{minted}
  404. \end{frame}
  405. \begin{frame}[fragile]{Jeder fängt mal klein an}
  406. \begin{minted}[bgcolor=bgl]{console}
  407. # git remote add origin http://git.open-desk.net/git/_.git
  408. # git push origin main
  409. ...
  410. To http://git.open-desk.net/git/_.git
  411. * [new branch] main -> main
  412. \end{minted}
  413. \end{frame}
  414. \begin{frame}[fragile]{Zieh, zeih, zieh!}
  415. \begin{minted}[bgcolor=bgr]{console}
  416. # git pull
  417. ...
  418. From http://git.open-desk.net/git/_
  419. * [new branch] main -> origin/main
  420. \end{minted}
  421. \end{frame}
  422. \begin{frame}[fragile]{Und jetzt alle zusammen}
  423. In beiden Ordnern einen Commit erzeugen
  424. \begin{minted}[bgcolor=bgl]{console}
  425. # git push origin main
  426. ...
  427. To http://git.open-desk.net/git/a.git
  428. ba998dd..a5069cc main -> main
  429. \end{minted}
  430. \begin{minted}[bgcolor=bgr]{console}
  431. # git push origin main
  432. To http://git.open-desk.net/git/_.git
  433. ! [rejected] main -> main (fetch first)
  434. error: failed to push some refs to 'http://git.open-desk.net/git/_.git'
  435. \end{minted}
  436. \end{frame}
  437. \begin{frame}[fragile]{Ständiges Hin und Her}
  438. \begin{minted}[bgcolor=bgr]{console}
  439. # git pull
  440. ...
  441. From http://git.open-desk.net/git/a
  442. + 07493c7...a5069cc main -> origin/main (forced update)
  443. Successfully rebased and updated refs/heads/main.
  444. # git push
  445. ...
  446. To http://git.open-desk.net/git/a.git
  447. a5069cc..baf125b main -> main
  448. \end{minted}
  449. \end{frame}
  450. \section{Alles immer bitte gleich richtig machen}
  451. \begin{frame}[fragile]{Ich meine es nur gut}
  452. \begin{itemize}
  453. \item Nutzt SSH-Schlüssel mit einem SSH-Agent. \\
  454. Tutorials gibt es von GitHub.
  455. \item Signiert eure Commits. \\
  456. Auch hier hilft GitHub weiter.
  457. \end{itemize}
  458. \end{frame}
  459. \begin{frame}[fragile]{Ja, wirklich}
  460. \begin{itemize}
  461. \item Konfiguriert euch einen Shell-Prompt für Git.
  462. \item Macht kleine und strukturierte Commits. \\
  463. \x{# git add -p -i .}
  464. \end{itemize}
  465. \end{frame}
  466. \begin{frame}[fragile]{Falls noch Zeit bleibt}
  467. \begin{itemize}
  468. \item \x{# git commit --amend}
  469. \item \x{# git stash}
  470. \item \x{# git blame}
  471. \item \x{# git rebase -i}
  472. \item \x{# git rebase --onto}
  473. \end{itemize}
  474. \end{frame}
  475. \begin{frame}
  476. \centering
  477. \vspace{3em}
  478. {
  479. \LARGE
  480. Danke
  481. }
  482. \vspace{3em}
  483. https://ohmygit.org
  484. \end{frame}
  485. \end{document}