\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Huluvu424242 (FunThomas424242)} \pdfinfo{ /Title (git-command-line.pdf) /Creator (Cheatography) /Author (Huluvu424242 (FunThomas424242)) /Subject (git command line Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{git command line Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Huluvu424242 (FunThomas424242)} via \textcolor{DarkBackground}{\uline{cheatography.com/19991/cs/3836/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Huluvu424242 (FunThomas424242) \\ \uline{cheatography.com/funthomas424242} \\ \uline{\seqsplit{github}.com/Huluvu424242} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 6th April, 2015.\\ Updated 29th April, 2019.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Grundbefehle}} \tn % Row 0 \SetRowColor{LightBackground} git clone \textless{}url\textgreater{} & Erzeugt eine lokale Kopie eines Git Repositories (es werden keine Schreibrechte ben{\"o}tigt) \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} git status & gibt den aktuellen Zustand der Working Copy aus \tn % Row Count 8 (+ 3) % Row 2 \SetRowColor{LightBackground} git commit -a & Fügt alle lokalen Änderungen dem Repository hinzu (ohne Übertragung an den Remote Host) \tn % Row Count 13 (+ 5) % Row 3 \SetRowColor{white} git reset -{}-hard origin/\textless{}branch-name\textgreater{} & Setzt local auf den HEAD Stand zurück. Lokale commits werden verworfen. \tn % Row Count 17 (+ 4) % Row 4 \SetRowColor{LightBackground} git clean -f -d & L{\"o}scht alle tempor{\"a}ren Dateien und Folder z.B. Files die nicht unter git Kontroller stehen \tn % Row Count 22 (+ 5) % Row 5 \SetRowColor{white} git push & Ver{\"o}ffentlichung der lokalen Commits auf dem Remote Repository \tn % Row Count 26 (+ 4) % Row 6 \SetRowColor{LightBackground} git branch & Liste alle lokal bekannten Branches auf \tn % Row Count 28 (+ 2) % Row 7 \SetRowColor{white} git branch \textless{}branch-name\textgreater{} & Erstellt lokal einen neuen Branch, bleibt aber auf dem Alten \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Grundbefehle (cont)}} \tn % Row 8 \SetRowColor{LightBackground} git branch -D \textless{}branch-name\textgreater{} & L{\"o}scht einen Branch unabh{\"a}ngig davon ob er im upstream existiert \tn % Row Count 4 (+ 4) % Row 9 \SetRowColor{white} git push origin -{}-delete \textless{}branch\textgreater{} & L{\"o}scht auch den Remote Branch erfolgreich \tn % Row Count 7 (+ 3) % Row 10 \SetRowColor{LightBackground} git checkout \textless{}branch-name\textgreater{} & Wechselt zu einem anderen Branch \tn % Row Count 9 (+ 2) % Row 11 \SetRowColor{white} git tag -{}-delete \textless{}tagname\textgreater{} & L{\"o}scht den Tag lokal \tn % Row Count 11 (+ 2) % Row 12 \SetRowColor{LightBackground} git push -{}-delete origin \textless{}tagname\textgreater{} & L{\"o}scht den Tag im Remote Repo \tn % Row Count 13 (+ 2) % Row 13 \SetRowColor{white} git stash & Lokale Änderungen als Backup auf einen internen Stack legen. \tn % Row Count 17 (+ 4) % Row 14 \SetRowColor{LightBackground} git stash pop & Lokale Änderungen aus dem Stack wiederholen \tn % Row Count 20 (+ 3) % Row 15 \SetRowColor{white} git remote add upstream \textless{}url\textgreater{} & Alias {\emph{upstream}} zum master eines Remote Repos definieren \tn % Row Count 23 (+ 3) % Row 16 \SetRowColor{LightBackground} \{\{nobreak\}\}git remote add –track \textless{}branch-name\textgreater{} upstream \textless{}url\textgreater{}\{\{nobreak\}\} & Alias {\emph{upstream}} zum Branch mit Repo URL definieren \tn % Row Count 27 (+ 4) % Row 17 \SetRowColor{white} git fetch upstream & Aktuellen Stand vom Alias {\emph{upstream}} herunterladen \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Grundbefehle (cont)}} \tn % Row 18 \SetRowColor{LightBackground} git merge \textless{}branch\textgreater{} - -no-commit - -no-ff & \textless{}branch\textgreater{} wird in den aktuell ausgecheckten branch gemerged (ohne commit) \tn % Row Count 4 (+ 4) % Row 19 \SetRowColor{white} git merge upstream/master & Merge der Änderungen vom Alias {\emph{upstream}} branch "master" in den lokalen branch wobei für konfliktfreie Änderungen ein Autocommit erfolgt. \tn % Row Count 12 (+ 8) % Row 20 \SetRowColor{LightBackground} git merge upstream/master - -no-commit - -no-ff & Merge der Änderungen vom Alias {\emph{upstream}} branch "master" in den lokalen branch wobei für konfliktfreie Änderungen KEIN Autocommit erfolgt. \tn % Row Count 20 (+ 8) % Row 21 \SetRowColor{white} git clone -{}-mirror \textless{}repourl\textgreater{} & Spiegelt ein Repository und kann zur Erstellung eines lokalen Backups verwendet werden. \tn % Row Count 25 (+ 5) % Row 22 \SetRowColor{LightBackground} git remote update & In einem Backup die remote Updates einspielen \tn % Row Count 28 (+ 3) % Row 23 \SetRowColor{white} git push \textless{}remotename\textgreater{} \textless{}commit SHA\textgreater{}:\textless{}remotebranchname\textgreater{} & Push eines ausgew{\"a}hlten lokalen commits. z.B. git push origin \seqsplit{712acff81033eddc90bb2b45e1e4cd031fefc50f:master} \tn % Row Count 34 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Grundbefehle (cont)}} \tn % Row 24 \SetRowColor{LightBackground} git branch -m new-name & Aktuellen lokalen Branch in new-name umbenennen \tn % Row Count 3 (+ 3) % Row 25 \SetRowColor{white} git branch -m old-name new-name & Einen lokalen Branch old-name in new-name umbenennen \tn % Row Count 6 (+ 3) % Row 26 \SetRowColor{LightBackground} git push origin :old-name new-name & Erst Prüfen!: Alten remote Branch l{\"o}schen und den neuen lokalen Branch pushen \tn % Row Count 10 (+ 4) % Row 27 \SetRowColor{white} git push origin -u new-name & Aktuellen Branch im Remote umbenennen \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{Alle lokalen Änderungen müssen um im Remote Repository sichtbar zu werden über den Mechanismus commit und push in das Remote Repository eingetragen werden (auch neu angelegte Branches).} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Github - Pull Requests aktuell halten}} \tn % Row 0 \SetRowColor{LightBackground} git clone \textless{}url\textgreater{} & Lokale Arbeitskopie erstellen \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git checkout \textless{}branch-name\textgreater{} & Auf den Pull Request wechseln \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} git remote add upstream \seqsplit{git://github.com/owner/projectname.git} & Alias {\emph{upstream}} für den Zugriff auf den Master definieren \tn % Row Count 8 (+ 4) % Row 3 \SetRowColor{white} git fetch upstream & Die Änderungen vom {\emph{master}} herunterladen \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} git merge upstream/master & Den {\emph{master}} in den lokalen Arbeitsstand mergen \tn % Row Count 14 (+ 3) % Row 5 \SetRowColor{white} git commit -a & Alles commiten wenn keine Konflikte mehr bestehen \tn % Row Count 17 (+ 3) % Row 6 \SetRowColor{LightBackground} git push & Nach dem erfolgreichen lokalen bauen, den aktuellen Stand ver{\"o}ffentlichen. \tn % Row Count 21 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{Generell sollte für jedes neue zu realisierende Feature ein eigener Feature Branch vom {\emph{master}} gezogen werden. \newline Hat man das Feature erfolgreich implementiert kann man auf github.com einen pull Request stellen. \newline Wenn dieser Pull Request vom Owner nicht gemerged werden kann weil es Änderungen auf dem {\emph{master}} gab dann hilft das oben beschriebene Vorgehen.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Neuen Branch mit lokalen Änderungen erstellen}} \tn % Row 0 \SetRowColor{LightBackground} git status & Gibt den aktuellen Branch aus und zeigt welche lokalen Änderungen vorliegen \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} git stash & Lokale Änderungen auf den Stack legen \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} git branch \textless{}neuer-branch-name\textgreater{} & Neuen Branch anlegen, Abspaltung vom Stand des aktuellen Branches \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} git checkout \textless{}neuer-branch-name\textgreater{} & Wechseln auf den neuen Branch \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} git stash pop & Lokale Änderungen vom Stack in den neuen Branch laden \tn % Row Count 14 (+ 3) % Row 5 \SetRowColor{white} git commit -a & Alle Änderungen auf den neuen Branch commiten \tn % Row Count 17 (+ 3) % Row 6 \SetRowColor{LightBackground} git push & Nach erfolgreichem lokalen Bauen die Änderungen und den neuen Branch an das Remote Repository publizieren. \tn % Row Count 22 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{Es gibt Tage das will man schnell mal was ausprobieren und dann funktioniert es gleich - unglaublich. Aber natürlich ist man mit den lokalen Änderungen gerade auf dem frisch ausgecheckten {\emph{master}} und will die Änderungen aber als neuen Feature Branch commiten - was tun? Das was oben steht ;)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Git für Pr{\"a}sentationen}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Wer in einer Pr{\"a}sentation zum n{\"a}chsten oder vorherigen Stand des Programmes springen m{\"o}chte ohne das Risiko von Schreibfehlern zu riskieren der sollte sich die Git Aliase prev und next anlegen. Damit l{\"a}sst sich zum vorhergehenden oder n{\"a}chsten Commit wechseln. \newline % Row Count 6 (+ 6) (Quelle: \seqsplit{https://coderwall.com/p/ok-iyg/git-prev-next)} \newline % Row Count 8 (+ 2) Die Aliase werden in der \textasciitilde{}/.gitconfig eingetragen \newline % Row Count 9 (+ 1) {[}alias{]} \newline % Row Count 10 (+ 1) prev = checkout HEAD\textasciicircum{}1 \newline % Row Count 11 (+ 1) next = "!sh -c 'git log -{}-reverse -{}-pretty=\%H master | awk \textbackslash{}"/\$(git rev-parse HEAD)/\{getline;print\}\textbackslash{}" | xargs git checkout'"% Row Count 14 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \end{document}