Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
373 lines (341 sloc) 13.7 KB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[9pt, % Schriftgröße {{{
a4paper, % A4
landscape,
halfparskip,
oneside, % Einseitig
DIV94, % Papiergröße
]{scrartcl} %%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Pakete {{{
\usepackage[utf8]{inputenc} % Umlaute etc.
\usepackage[T1]{fontenc} % T1-kodierte Fonts
\usepackage{ae,aecompl} % Kodierung für PDF
\usepackage{ngerman} % Deutsche Trennungen,
% dt. Begriffe
\usepackage{setspace} % Single- oder Onehalfspacing
\setcounter{tocdepth}{4} % 4 Hirarchien im Inhaltsv.
\usepackage{times} % Times als Schrift
\usepackage{amsmath,amssymb,amstext}% Mathematische Symbole
\usepackage{exscale} % Skalierung von Summen-c und Int.-zeichen
\usepackage{url} % Darstellung von URLs
\usepackage{calc}
%%% Optional, je nach Dokument
% \usepackage{listings} % Quelltext-Listings
% \usepackage{units} % Technische Units
% \usepackage{psfrag} % Ersetzts PS-Schriften
\usepackage{color} % Farben in LaTeX
% \usepackage{floatflt} % Textumflossene Bilder...
% \usepackage{picins} % Textumflossene Bilder
\usepackage{textcomp} % Spezielle Zeichen
\usepackage{gensymb} % Spezielle Zeichen
% \usepackage{eurosym} % Euro-Symbol
% \usepackage{currvita} % Befehle für CVs
\usepackage{ifpdf} % Wird ein PDF erstellt?
%%% Layout
\usepackage{scrpage2} % KOMA-Überschriften und -Fußzeilen.
%%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% PDF {{{
\ifpdf
\usepackage[pdftex]{graphicx}
\DeclareGraphicsExtensions{.pdf}
\pdfcompresslevel=9
\usepackage[%
pdftex=true,
backref=true,
colorlinks=true,
bookmarks=true,
breaklinks=true,
linktocpage=true,
bookmarksopen=false,
bookmarksnumbered=false,
pdfpagemode=None
]{hyperref}
\hypersetup{
pdftitle={},
pdfauthor={Julius Plenz},
pdfsubject={},
pdfcreator={LaTeX2e and pdfLaTeX},
pdfproducer={},
pdfkeywords={}
}
\else
\usepackage[dvips]{graphicx}
\DeclareGraphicsExtensions{.eps}
% \usepackage[%
% dvips,
% breaklinks=true,
% colorlinks=false
% ]{hyperref}
\fi
%%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Eigene Funktionen {{{
%%% Beispiel: \bild{200pt}{foo}{That's a foo\ldots}
\newcommand{\bild}[3]{
\begin{figure}
\includegraphics[width=#1, keepaspectratio=true]{#2}
\caption{#3}
\label{#2}
\end{figure}
}
%% \floatimg{filename}{caption+label}{r/l}{8cm}
\newcommand{\floatimg}[4]{
\piccaption{#2}
\parpic[#3]{\includegraphics[width=#4]{#1}}
}
%%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Pagestyle {{{
% \pagestyle{scrheadings}
% \pagestyle{fancyhdrs}
\pagestyle{empty}
%%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Seitenkopf- und -Fußzeilen {{{
\automark[subsection]{section} % \left- und \rightmark bekommen Inhalt
%%% Oben: Links, Mitte, Rechts
\ihead[]{}
\chead[]{}
\ohead[]{}
%%% Unten: Links, Mitte, Rechts
\ifoot[]{}
\cfoot[]{}
\ofoot[]{}
%%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz}
\usetikzlibrary{shapes,decorations,shadows}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Sonstiges {{{
% \setlength{\parindent}{17pt} % Einzug 17pt,
% \setlength{\parskip}{2pt} % keine Leerzeilen.
% \textwidth 127mm % Textbreite
% \textheight 235mm % Texthöhe
% \topmargin -5mm % Abstand oben
% \oddsidemargin 7mm % Abstand Links, onepage
%\onehalfspacing % Zeilenabstand: Bei korrektur,
\singlespacing % bei Abgabe
% Punkt- und Komma Abstände bei Tausendern/
% Dezimalzahlen ans deutsche anpassen!
\mathcode`,="013B
\mathcode`.="613A
\setlength{\emergencystretch}{2em} % Notfallsstreckung
\addtolength{\voffset}{10pt}
% Kommandoänderungen
\renewcommand{\figurename}{Abb.} % Bildunterschriften: Abb. anstatt Fig.
%\renewcommand*{\cvheadingfont}{\raggedleft\Huge\bfseries} % CV: Überschriften
%%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Inhalt {{{
\begin{tikzpicture}
\draw (0,1) node[anchor=north west,font=\Huge\bf\fontfamily{phv}\selectfont]{Git -- der Spickzettel}
(.1cm,.3cm) -- (28.2cm,.3cm)
([xshift=1mm]23.7cm,.7cm)
node[font=\footnotesize,color=black!85,anchor=north east]{
\copyright{} 2010 V.\,Hänel, J.\,Plenz
}
++(0,.3cm)
node[font=\footnotesize,color=black!85,anchor=north east]{
Version vom \today
}
([xshift=1mm]23.7cm,.7cm)
node[font=\footnotesize,color=black!85,anchor=north west]{
Creative-Commons-Lizenz 3.0 (By,Nc,Sa)
}
++(0,.3cm)
node[font=\footnotesize,color=black!85,anchor=north west]{
https://github.com/esc/git-cheatsheet-de
}
;
\draw
(0,0) node[anchor=north west,text width=7.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
(linksoben)
{
\subsubsection*{Repositories klonen oder erstellen}
\begin{tabular}{ll}
\texttt{git clone git://}\ldots & Klonen (Git-Protokoll)\\
\texttt{git clone ssh://}\ldots & Klonen (SSH)
\vspace*{.2cm}\\
\texttt{cd \emph{projekt}} & \\
\texttt{git init} & Neues Repository \\
\texttt{git add .} & erstellen\\
\texttt{git commit} &
\end{tabular}
}
++(0,-3.6cm) node[below right,text width=7.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Änderungen untersuchen}
\hspace{1mm}
\begin{minipage}{7.5cm}
Jedes der Kommandos akzeptiert optional als Argument eine
\emph{Referenz} auf einen oder mehrere Commits (siehe zweite
Spalte).
\end{minipage}
\begin{tabular}{ll}
\texttt{git log} & Zusammenfassung der Änderungen\\
\texttt{git show} & Detaillierte Ansicht eines Commits\\
\texttt{git diff} & Unterschiede mit \texttt{diff} anzeigen\\
\texttt{git blame} & Wer hat welche Zeile geändert?\\
\texttt{gitk -{}-all} & Grafische Ansicht\\
\texttt{tig} & Curses-Frontend für Git
\end{tabular}
}
++(0,-4.6cm) node[below right,text width=7.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Nächsten Commit vorbereiten}
\begin{tabular}{ll}
\texttt{git add} & Datei hinzufügen\\
\texttt{git add -p} & Teile einer Datei hinzufügen\\
\texttt{git rm} & Datei löschen\\
\texttt{git mv} & Datei verschieben\\
\texttt{git commit} & Commit erstellen\\
\ldots\quad\texttt{-m '\emph{msg}'} & mit Beschreibung \emph{msg}\\
\ldots\quad\texttt{-{}-amend} & Letzten Commit verbessern\\
\end{tabular}
}
% Als Visualisierung brauchbar?
++(1.4cm,-4.3cm) node[rounded corners=2pt,fill=gray!25,minimum height=1cm] (w) {Working Directory}
++(1.7,0) node[single arrow,fill=green!50] {add}
++(1.1,0) node[rounded corners=2pt,fill=gray!25,minimum height=1cm] (i) {Index}
++(1.1,0) node[single arrow,fill=green!50] {commit}
++(1.7,0) node[rounded corners=2pt,fill=gray!25,minimum height=1cm] (r) {Repository}
;
\draw[->,thick] (r.south) .. controls +(0,-1.2) and +(0,-1.2) .. node[fill=green!50,above=3pt]{reset} (i.south);
\draw[->,thick] (r.south) .. controls +(0,-1.8) and +(0,-1.8) .. node[fill=green!50,below=1pt](co){checkout} (w.south);
\draw (co)
++(-4.2cm,-0.8cm) node[below right,text width=7.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Index vs. Working Directory}
\begin{tabular}{ll}
\texttt{git diff -{}-cached} & Änderung zwischen Index \\
& und Repository (\texttt{HEAD})\\
\texttt{git rm -{}-cached} & Datei nicht mehr beachten\\
\texttt{git reset \emph{ref}} & Den Index auf \emph{ref} setzen;\\
& \emph{Working Dir.} unverändert\\
\texttt{git checkout} & Index und \emph{WD} ändern\\
\ldots\quad\texttt{-b \emph{branch}} & Zu neuem \emph{branch} wechseln\\
\end{tabular}
};
\draw (linksoben.north west)
++(8cm,0) node[anchor=north west,text width=8.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
(zweite-spalte)
{
\subsubsection*{Referenzen}
\begin{tabular}{ll}
\texttt{HEAD} & Letzter Commit\\
\texttt{HEAD$^\wedge$} & Vorletzter Commit\\
\texttt{HEAD\texttildelow\emph{n}} & \emph{n}-ter letzter Commit\\
\texttt{master} & Branch-Name\\
\texttt{v2.6.17} & Tag-Name (z.\,B. für Versionierung)\\
\texttt{a..b} & Alle Commits zwischen \texttt{a} und \texttt{b}\\
\texttt{master..} & Commits, die noch nicht in \texttt{master} sind\\
\texttt{44ac95d}\ldots & Objekt-Referenz (Commit, Tree, etc.)\\
\end{tabular}
}
++(0,-4.1cm) node[below right,text width=8.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Branches}
\begin{tabular}{ll}
\texttt{git branch \emph{name}} & Branch \emph{name} erstellen\\
\texttt{git checkout \emph{name}} & Branch \emph{name} auschecken\\
\texttt{git merge \emph{feature}} & \emph{feature} integrieren\\
\texttt{git rebase \emph{basis}} & Aktuellen Branch auf neue \\
& \emph{basis} aufbauen\\
\ldots\;\texttt{-{}-interactive} & Commits ordnen und anpassen\\
\end{tabular}
}
++(0,-3.3cm) node[below right,text width=8.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Merge-Konflikte beheben}
\begin{tabular}{ll}
\texttt{git diff -{}-ours} & Unterschied zu \emph{unserer}\\
\ldots\quad\texttt{-{}-theirs} & \ldots{} und \emph{deren} Version\\
\texttt{gitk -{}-merge} & Relevante Commits untersuchen\\
\texttt{git mergetool} & Three-Way-Merge\\
\texttt{git add}, \texttt{commit} \ldots & Änderungen aufnehmen\\
\texttt{git reset -{}-hard} & Merge abbrechen\\
\end{tabular}
}
++(0,-3.4cm) node[below right,text width=8.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Remote Repositories}
\begin{tabular}{ll}
\texttt{git remote} & Remote Repositories verwalten \\
\texttt{git fetch} \ldots & Neue Commits herunterladen \\
\texttt{git pull} \ldots & \ldots{} und gleich mergen \\
\end{tabular}
}
++(0,-2.3cm) node[below right,text width=8.5cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Änderungen veröffentlichen}
\begin{tabular}{ll}
\texttt{git push} & Commits hochladen \\
\texttt{git tag} & Commit markieren (z.\,B.\\
& für eine neue Version)\\
\texttt{git format-patch} & Änderungen im Patch-Format\\
& exportieren, für E-Mail-Versand \\
\end{tabular}
}
% Eigene Anmerkungen
[anchor=north west,draw=gray,dashed,rounded corners] ++(0,-3.1cm) rectangle +(20.3cm,-2.7cm)
++(0,0) node[color=gray]{Platz für eigene Anmerkungen!}
;
\draw (zweite-spalte.north west)
++(9.0cm,0) node[below right,text width=11.0cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Weitere praktische Kommandos}
\begin{tabular}{ll}
\texttt{git grep \emph{expr}} & In allen Dateien nach \emph{expr} suchen\\
\texttt{git stash} & Änderungen temporär in den Hintergrund schieben\\
\texttt{git clean} & Nicht von Git verwaltete Dateien löschen\\
\texttt{git bisect} & Commit finden, der ein bestimmtes Problem verursacht\\
\texttt{git archive} & Tar-Ball des Projektes erzeugen\\
\texttt{git shortlog} & Anzahl der Commits zählen (per \texttt{-s -n})\\
\end{tabular}
}
++(0,-3.5cm) node[below right,text width=11.0cm,rounded corners,fill=gray!15,inner sep=1ex,drop shadow]
{
\subsubsection*{Beispielhafte Programmaufrufe}
\textbf{Einen leeren Commit erstellen}, praktisch z.\,B. für den
\emph{initial commit}:\\
\texttt{\$ git commit -{}-allow-empty -m 'leer'}\\[.8em]
Herausfinden, durch welchen Commit eine \textbf{Datei gelöscht} wurde:\\
\texttt{\$ git log -{}-diff-filter=D \emph{datei}}\\[.7em]
\textbf{Einen Patch} der Änderungen erstellen, die zwischen dem Tag \texttt{v1.6} und
dem Branch \emph{neues-feature} bestehen:\\
\texttt{\$ git diff v1.6..neues-feature > meine-aenderungen.patch}\\[.8em]
\textbf{ASCII-Baumdiagramm} aller Commits anzeigen:\\
\texttt{\$ git log -{}-graph -{}-oneline -{}-decorate -{}-all}\\[.8em]
\textbf{Alle unnötigen Dateien löschen}, Änderungen verwerfen und
mit einer "`sauberen"' Version von \emph{master} starten:
\begin{verbatim}$ git checkout -f master
$ git clean -dfx\end{verbatim}
\textbf{Throw-Away-Integration:} Testen, ob ein Merge
funktionieren würde, ohne tatsächlich \texttt{master} zu ändern:
\begin{verbatim}$ git checkout -b integrate master
$ git merge feature\end{verbatim}
\textbf{Den letzten Commit in zwei kleinere aufteilen} (siehe auch
\texttt{man git-rebase}):
\begin{verbatim}$ git rebase -i HEAD^
(pick durch edit ersetzen, speichern)
$ git reset HEAD^
$ git add -p
$ git commit -m 'Erster Teil'
$ git add -u
$ git commit -m 'Zweiter Teil'\end{verbatim}
}
;
\end{tikzpicture}
%%% }}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%% vim:set fdm=marker:
Jump to Line
Something went wrong with that request. Please try again.