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

\year=2021
\month=9
\day=14
\documentclass[aspectratio=1610,xcolor=dvipsnames]{beamer}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{german}
\usepackage[font=scriptsize]{caption}
\usepackage{fontawesome}
\usepackage{graphicx}
\usepackage{tikzfig}
\usetikzlibrary{positioning}
\graphicspath{{./figures/}}
\usepackage{csquotes}
\usepackage{fancyvrb}
\usepackage[
backend=biber,
style=verbose-ibid,
block=ragged,
]{biblatex}
\addbibresource{presi.bib}
\usecolortheme{seahorse}
\setbeamerfont{footnote}{size=\tiny}
\usepackage{minted}
\usemintedstyle{friendly}
\setminted{
baselinestretch=1,
breaklines=true,
autogobble=true,
bgcolor=lightgray!50,
}
\newmintinline[x]{console}{}
\colorlet{bgl}{cyan!50!lightgray!50}
\colorlet{bgr}{orange!50!lightgray!50}
\title{Git SCM}
\subtitle{Crash-Course in Versionsverwaltung and kolaborativem bearbeiten von Textdateien}
\author{Dustin Frisch\\
Fachbereich Angewandte Informatik\\
Hochschule Fulda\\
Fulda, Deutschland\\
E-Mail: {\tt dustin.frisch@ai.hs-fulda.de}}
\begin{document}
\frame{\titlepage}
\begin{frame}{Agenda}
\tableofcontents
\end{frame}
\section{Was soll das alles?}
\begin{frame}{Was ist Versionverwaltung?}
\begin{columns}[t]
\begin{column}{0.5\textwidth}
\centering
\large{Ohne Versionverwaltung}
\begin{figure}[H]
\begin{tikzpicture}[]
\tikzstyle{state}+=[circle, draw=cyan!60, fill=cyan!5, very thick, minimum size=2.5em]
\tikzstyle{file}+=[rectangle, draw=green!60, fill=green!5, very thick, minimum size=2.5em]
\tikzstyle{update}+=[->, thick, dotted]
\tikzstyle{save}+=[->, thick]
\node[state](s1){+A};
\node[state](s2)[right=1em of s1]{+B};
\node[state](s3)[right=1em of s2]{-A};
\node[state](s4)[right=1em of s3]{+C};
\node[file](f) at (2,-3) {$doc$};
\draw[update] (s1.east) -- (s2.west);
\draw[update] (s2.east) -- (s3.west);
\draw[update] (s3.east) -- (s4.west);
\draw[save] (s1.south) -- ([xshift=-0.9em] f.north);
\draw[save] (s2.south) -- ([xshift=-0.3em] f.north);
\draw[save] (s3.south) -- ([xshift=0.3em] f.north);
\draw[save] (s4.south) -- ([xshift=0.9em] f.north);
\end{tikzpicture}
\end{figure}
\end{column}
\begin{column}{0.5\textwidth}
\centering
\large{Mit Versionverwaltung}
\begin{figure}[H]
\begin{tikzpicture}[]
\tikzstyle{state}+=[circle, draw=cyan!60, fill=cyan!5, very thick, minimum size=2.5em]
\tikzstyle{file}+=[rectangle, draw=green!60, fill=green!5, very thick, minimum size=2.5em]
\tikzstyle{update}+=[->, thick, dotted]
\tikzstyle{save}+=[->, thick]
\node[state](s1){+A};
\node[state](s2)[right=1em of s1]{+B};
\node[state](s3)[right=1em of s2]{-A};
\node[state](s4)[right=1em of s3]{+C};
\node[file](f1)[below=2 of s1]{$doc_1$};
\node[file](f2)[below=2 of s2]{$doc_2$};
\node[file](f3)[below=2 of s3]{$doc_3$};
\node[file](f4)[below=2 of s4]{$doc_4$};
\draw[update] (s1.east) -- (s2.west);
\draw[update] (s2.east) -- (s3.west);
\draw[update] (s3.east) -- (s4.west);
\draw[save] (s1.south) -- (f1.north);
\draw[save] (s2.south) -- (f2.north);
\draw[save] (s3.south) -- (f3.north);
\draw[save] (s4.south) -- (f4.north);
\end{tikzpicture}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\begin{frame}{Wo kann ich das einsetzen?}
\begin{itemize}
\item Source-Code
\item Konfiguration
\item Dokumente
\item Daten
\end{itemize}
\vspace{1em}
Also alles, was \emph{Text} ist.
\end{frame}
\begin{frame}{Was bringt mir das?}
\centering
{
\fontsize{40}{48}\selectfont
Zeitmaschinen
}\\
\vspace{1em}
\small{und}\\
\vspace{1em}
{
\fontsize{40}{48}\selectfont
Paralleluniversen
}
\end{frame}
\section{Warum jetzt genau Git?}
\begin{frame}{Kurze Histore}
\begin{figure}[H]
\begin{tikzpicture}[]
\tikzstyle{kind}+=[rectangle, very thick, minimum size=3.5em]
\tikzstyle{prod}+=[]
\node[kind, draw=red!90!yellow!60, fill=red!90!yellow!5] (l) at(0,6) {Lokale Versionsverwaltung};
\node[kind, draw=red!60!yellow!60, fill=red!60!yellow!5] (c) at(0,3) {Zentrale Versionsverwaltung};
\node[kind, draw=red!30!yellow!60, fill=red!30!yellow!5] (d) at(0,0) {Verteilte Versionsverwaltung};
\draw[->,thick] (l.south) -- (c.north);
\draw[->,thick] (c.south) -- (d.north);
\node[prod] (l1) [right=of l, yshift=+1em] {SCCS};
\node[prod] (l2) [right=of l, yshift=-1em] {RCS};
\node[prod] (c1) [right=of c, yshift=+1em] {CSV};
\node[prod] (c2) [right=of c, yshift=-1em] {SVN};
\node[prod] (d1) [right=of d, yshift=+1em] {Git};
\node[prod] (d2) [right=of d, yshift= 0em] {Bazaar};
\node[prod] (d3) [right=of d, yshift=-1em] {Mercurial};
\draw[->] (l.east) -- (l1.west);
\draw[->] (l.east) -- (l2.west);
\draw[->] (c.east) -- (c1.west);
\draw[->] (c.east) -- (c2.west);
\draw[->] (d.east) -- (d1.west);
\draw[->] (d.east) -- (d2.west);
\draw[->] (d.east) -- (d3.west);
\end{tikzpicture}
\end{figure}
\end{frame}
\begin{frame}{Git is everywhere}
\begin{columns}[c]
\begin{column}{0.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{logos/GitHub.png}
\end{column}
\begin{column}{0.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{logos/Codeberg.png}
\end{column}
\end{columns}
\vspace{1em}
\begin{columns}[c]
\begin{column}{0.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{logos/GitLab.png}
\end{column}
\begin{column}{0.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{logos/SourceHut.png}
\end{column}
\end{columns}
\vspace{1em}
\begin{columns}[c]
\begin{column}{0.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{logos/Gitea.png}
\end{column}
\begin{column}{0.5\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{logos/Bitbucket.png}
\end{column}
\end{columns}
\end{frame}
\section{Einrichtung und Installation}
\begin{frame}[fragile]{Installation}
\begin{description}
\item[Windows] https://gitforwindows.org/ oder \\
\x^# choco install git^
\item[Linux] \x^# sudo dnf install git-all^ oder \\
\x^# sudo apt install git-all^ oder ...
\item[macOS] \x^# git --version^
\end{description}
\end{frame}
\begin{frame}[fragile]{Einrichtung}
\begin{minted}{console}
# git config --global user.name "Dustin Frisch"
# git config --global user.email "dustin.frisch@ai.hs-fulda.de"
\end{minted}
\end{frame}
\begin{frame}
\centering
\LARGE
Pause
\end{frame}
\section{Aller Anfang ist schwer}
\begin{frame}[fragile]{Neues Projekt}
Neuen Ordner anlegen und in diesen wechseln.
\begin{minted}{console}
# git init
Initialized empty Git repository in /home/fooker/tmp/myproject/.git/
\end{minted}
\end{frame}
\begin{frame}[fragile]{Den überblick behalten}
Eine Datei in dem Ordner anlegen.
\begin{minted}{console}
# git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
test.c
nothing added to commit but untracked files present (use "git add" to track)
\end{minted}
\end{frame}
\begin{frame}[fragile]{Der Staging-Bereich}
\begin{minted}{console}
# git add test.c
# git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: test.c
\end{minted}
\end{frame}
\begin{frame}[fragile]{Mein erstes mal}
\begin{minted}{console}
# git commit
main (root-commit) 27cda20] A wonderful commit message
1 file changed, 6 insertions(+)
create mode 100644 test.c
# git status
On branch main
nothing to commit, working tree clean
\end{minted}
\end{frame}
\begin{frame}[fragile]{Oh, ein wie konnte das nur passieren}
Die Datei in dem Ordner wird geändert.
\begin{minted}{console}
# git add test.c
# git commit
\end{minted}
\end{frame}
\begin{frame}[fragile]{Was bisher geschah...}
\begin{minted}{console}
# git log
commit 7163f25b8e477a43accc28c30f3bd4351a2d72a2
Author: Dustin Frisch <fooker@lab.sh>
Date: Mon Oct 18 22:12:28 2021 +0200
Fixed dumb mistake
commit 27cda204ad4caae123b44f1fc8d3ac6645e66d3f
Author: Dustin Frisch <fooker@lab.sh>
Date: Mon Oct 18 22:07:31 2021 +0200
A wonderful commit message
\end{minted}
\end{frame}
\begin{frame}[fragile]{So langsam wird es}
Eine weitere Datei anlegen.
\begin{minted}{console}
# git add example.c
# git commit -m "Added example"
\end{minted}
\end{frame}
\begin{frame}[fragile]{Namesgebung ist schwierig}
Eine Datei umbenennen.
\begin{minted}{console}
# git status
On branch main
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: test.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
main.c
no changes added to commit (use "git add" and/or "git commit -a")
\end{minted}
\end{frame}
\begin{frame}[fragile]{Namensgebung ist schwierig}
\begin{minted}{console}
# git add test.c main.c
# git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
renamed: test.c -> main.c
# git commit -m "Naming fixed"
\end{minted}
\end{frame}
\begin{frame}[fragile]{Und weg damit}
Eine Datei löschen.
\begin{minted}{console}
# git rm example.c
# git commit -m "This was a mistake"
\end{minted}
\end{frame}
\begin{frame}[fragile]{Was hab ich nur getan}
Eine Datei ändern.
\begin{minted}{console}
# git diff
\end{minted}
\end{frame}
\begin{frame}[fragile]{Keine Fehler}
\begin{minted}{console}
# git restore main.c
\end{minted}
\end{frame}
\begin{frame}[fragile]{Was werde ich nur getan haben}
Eine Datei ändern.
\begin{minted}{console}
# git add main.c
# git diff --staged
\end{minted}
\end{frame}
\begin{frame}[fragile]{Nee, doch nicht}
Datei nochmal ändern
\begin{minted}{console}
# git restore --staged main.c
\end{minted}
\end{frame}
\section{Ein Baum ist ein Baum ist ein Baum}
\begin{frame}[fragile]{Alles hat ein Ende}
\begin{minted}{console}
# git branch
* main
\end{minted}
\end{frame}
\begin{frame}[fragile]{Nur der Baum hat viele}
\begin{minted}{console}
# git branch feature-x
# git branch
feature-x
* main
\end{minted}
\end{frame}
\begin{frame}[fragile]{Wer die Wahl hat}
\begin{minted}{console}
# git checkout feature-x
Switched to branch 'feature-x'
# git branch
* feature-x
main
\end{minted}
\end{frame}
\begin{frame}[fragile]{Als währe nichts gewesen}
Ein paar Commits erzeugen.
\begin{minted}{console}
# git checkout main
Switched to branch 'main'
# git log
...
\end{minted}
\end{frame}
\begin{frame}[fragile]{Realität ist subjektiv}
Eine paar Commits erzeugen.
\begin{minted}{console}
# git checkout feature-x
Switched to branch 'feature-x'
# git log
...
\end{minted}
\end{frame}
\begin{frame}[fragile]{Zusammen was zusammen gehört}
\begin{minted}{console}
# git merge main
Merge made by the 'recursive' strategy.
...
# git log
...
\end{minted}
\end{frame}
\begin{frame}
\centering
\LARGE
Pause
\end{frame}
\section{Mein, dein. Das sind doch bürgerliche Kategorien}
\begin{frame}[fragile]{So klein und schon bei den Sturmtruppen?}
\begin{minted}[bgcolor=bgr]{console}
# git clone http://git.open-desk.net/git/_.git project
\end{minted}
\begin{minted}[bgcolor=bgr]{console}
# git remote -v
origin http://git.open-desk.net/git/_.git (fetch)
origin http://git.open-desk.net/git/_.git (push)
\end{minted}
\end{frame}
\begin{frame}[fragile]{Jeder fängt mal klein an}
\begin{minted}[bgcolor=bgl]{console}
# git remote add origin http://git.open-desk.net/git/_.git
# git push origin main
...
To http://git.open-desk.net/git/_.git
* [new branch] main -> main
\end{minted}
\end{frame}
\begin{frame}[fragile]{Zieh, zeih, zieh!}
\begin{minted}[bgcolor=bgr]{console}
# git pull
...
From http://git.open-desk.net/git/_
* [new branch] main -> origin/main
\end{minted}
\end{frame}
\begin{frame}[fragile]{Und jetzt alle zusammen}
In beiden Ordnern einen Commit erzeugen
\begin{minted}[bgcolor=bgl]{console}
# git push origin main
...
To http://git.open-desk.net/git/a.git
ba998dd..a5069cc main -> main
\end{minted}
\begin{minted}[bgcolor=bgr]{console}
# git push origin main
To http://git.open-desk.net/git/_.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'http://git.open-desk.net/git/_.git'
\end{minted}
\end{frame}
\begin{frame}[fragile]{Ständiges Hin und Her}
\begin{minted}[bgcolor=bgr]{console}
# git pull
...
From http://git.open-desk.net/git/a
+ 07493c7...a5069cc main -> origin/main (forced update)
Successfully rebased and updated refs/heads/main.
# git push
...
To http://git.open-desk.net/git/a.git
a5069cc..baf125b main -> main
\end{minted}
\end{frame}
\section{Alles immer bitte gleich richtig machen}
\begin{frame}[fragile]{Ich meine es nur gut}
\begin{itemize}
\item Nutzt SSH-Schlüssel mit einem SSH-Agent. \\
Tutorials gibt es von GitHub.
\item Signiert eure Commits. \\
Auch hier hilft GitHub weiter.
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Ja, wirklich}
\begin{itemize}
\item Konfiguriert euch einen Shell-Prompt für Git.
\item Macht kleine und strukturierte Commits. \\
\x{# git add -p -i .}
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Falls noch Zeit bleibt}
\begin{itemize}
\item \x{# git commit --amend}
\item \x{# git stash}
\item \x{# git blame}
\item \x{# git rebase -i}
\item \x{# git rebase --onto}
\end{itemize}
\end{frame}
\begin{frame}
\centering
\vspace{3em}
{
\LARGE
Danke
}
\vspace{3em}
https://ohmygit.org
\end{frame}
\end{document}