\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{schmidt7}
\pdfinfo{
  /Title (git.pdf)
  /Creator (Cheatography)
  /Author (schmidt7)
  /Subject (Git 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 Cheat Sheet}}}} \\
    \normalsize{by \textcolor{DarkBackground}{schmidt7} via \textcolor{DarkBackground}{\uline{cheatography.com/30462/cs/9075/}}}
\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}schmidt7 \\
  \uline{cheatography.com/schmidt7} \\
  \end{tabulary}
\vfill
\columnbreak
\begin{tabulary}{5.8cm}{L}
  \SetRowColor{FootBackground}
  \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}}  \\
   \vspace{-2pt}Not Yet Published.\\
   Updated 14th September, 2016.\\
   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{multicols*}{2}

\begin{tabularx}{8.4cm}{x{4.08 cm} x{3.92 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Getting started}}  \tn
% Row 0
\SetRowColor{LightBackground}
`{\bf{git clone}} \seqsplit{ssh://domain.org/project.git`} & Get a copy of an extern project. \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
`{\bf{git init}} myProject` & Creates a local new project. \tn 
% Row Count 5 (+ 2)
% Row 2
\SetRowColor{LightBackground}
`{\bf{git config}} -{}-global user.name "Max Mustermann"` & Sets your displayed name (obligatory). \tn 
% Row Count 8 (+ 3)
% Row 3
\SetRowColor{white}
`{\bf{git config}} -{}-global user.mail \seqsplit{"max@mustermann.de"`} & Sets your email address (obligatory). \tn 
% Row Count 11 (+ 3)
% Row 4
\SetRowColor{LightBackground}
`{\bf{git config}} -{}-global -{}-list` & Verify global settings. \tn 
% Row Count 13 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{8.4cm}}{Global configuration is saved in the file `.gitconfig` file in your home directory. Local configuration (`git config -{}-local`) in each repository in the file `.git/config`}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Exploring the repository}}  \tn
% Row 0
\SetRowColor{LightBackground}
`{\bf{git status}}` & Important command to see the current state\{\{nl\}\}of the local repository. \tn 
% Row Count 4 (+ 4)
% Row 1
\SetRowColor{white}
`{\bf{git log}}` & Shows the history of the project. \tn 
% Row Count 6 (+ 2)
% Row 2
\SetRowColor{LightBackground}
`{\bf{git log}} -{}-graph\{\{nl\}\}-{}-oneline` & Useful option for a larger overview. \tn 
% Row Count 8 (+ 2)
% Row 3
\SetRowColor{white}
`{\bf{git branch}}` & Shows the current branch and all local branches\{\{nl\}\}that are available. (`-a` for all available branches). \tn 
% Row Count 14 (+ 6)
% Row 4
\SetRowColor{LightBackground}
`{\bf{git blame}} {\emph{\$file}}` & see who edited the file and when. \tn 
% Row Count 16 (+ 2)
% Row 5
\SetRowColor{white}
`{\bf{gitk}}` & graphical tool to explore the history. \tn 
% Row Count 18 (+ 2)
% Row 6
\SetRowColor{LightBackground}
`{\bf{git gui}}` & graphical tool for git. \tn 
% Row Count 20 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{x{3.44 cm} x{4.56 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Basic commands}}  \tn
% Row 0
\SetRowColor{LightBackground}
`{\bf{git add}} {\emph{\$file}}` & Adds {\emph{\$file}} to the index/staging area \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
`{\bf{git commit}}` & Saves all changes that are added to the index/staging area in a commit/snapshot in your local repository. \tn 
% Row Count 7 (+ 5)
% Row 2
\SetRowColor{LightBackground}
`{\bf{git reset}} {\emph{\$file}}` & Removes {\emph{\$file}} from the index/staging area. Useful when the file was added accidentally. \tn 
% Row Count 12 (+ 5)
% Row 3
\SetRowColor{white}
`{\bf{git checkout}} {\emph{\$file}}` & Restores {\emph{\$file}} to the state of the latest commit. All local changes for this file will be deleted. \tn 
% Row Count 17 (+ 5)
% Row 4
\SetRowColor{LightBackground}
`{\bf{git fetch}}` & Gets the most recent version from the remote repository. Changes won't be applied to the working directory. Might be useful when a conflict with the local version is expected. \tn 
% Row Count 25 (+ 8)
% Row 5
\SetRowColor{white}
`{\bf{git pull}}` & Like {\bf{git fetch}}, but changes are immediately applied to the working directory. \tn 
% Row Count 29 (+ 4)
% Row 6
\SetRowColor{LightBackground}
`{\bf{git mv}} {\emph{\$name1}} {\emph{\$name2}}` & To move a file within Git. Should be used to preserve the file-history \tn 
% Row Count 33 (+ 4)
\end{tabularx}
\par\addvspace{1.3em}

\vfill
\columnbreak
\begin{tabularx}{8.4cm}{x{3.44 cm} x{4.56 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Basic commands (cont)}}  \tn
% Row 7
\SetRowColor{LightBackground}
`{\bf{git rm}} {\emph{\$filename}}` & Removes the file \tn 
% Row Count 2 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Things that might be useful}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{How to change the editor for commit messages?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`{\bf{git config}} -{}-global core.editor={\emph{editorname}}`} \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{How to learn more about a certain command?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`{\bf{git {\emph{command}}}} -{}-help`} \tn 
% Row Count 5 (+ 2)
% Row 2
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{How to specify a range of commits?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Via two dots. For example: `{\bf{git log}} 9e45..e312`\{\{nl\}\} The SHA1-ID can be found in the history.} \tn 
% Row Count 9 (+ 4)
% Row 3
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{What does HEAD\textasciicircum{}2 mean?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Two commits(snapshots) behind HEAD, the current snapshot-pointer. Note that `\textasciicircum{}` and `\textasciitilde{}` are aequivalent and you can combine all notations. \{\{nl\}\}`HEAD\textasciicircum{}1` is equivalent to `HEAD\textasciitilde{}`\{\{nl\}\}`HEAD\textasciicircum{}\textasciicircum{}\textasciitilde{}2` is equivalent to `HEAD\textasciitilde{}3\textasciicircum{}`} \tn 
% Row Count 15 (+ 6)
% Row 4
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{I only made small changes in each line. How can see them directly?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Use `{\bf{git diff}} {\emph{\$filename}} -{}-word-diff=color`} \tn 
% Row Count 19 (+ 4)
% Row 5
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{I want to introduce the same commit that was made in another branch in my branch} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Use `{\bf{git cherry-pick}} {\emph{\$ID}}`} \tn 
% Row Count 22 (+ 3)
% Row 6
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{I know that there is a bug introduced between two far away versions. Can git help me to find the commit that introduced the bug?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Yes, read the documentation for `{\bf{git bisect}}`} \tn 
% Row Count 27 (+ 5)
% Row 7
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{{\emph{\$IDs}} are hard to remember. What can I do?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}If you often have to refer to a certain commit/snapshot of your project you can use `{\bf{git tag}} -a {\emph{\$tagname}} {\emph{\$ID}}` to give it a name that is easier to remember. This is especially useful to remember the commit of a published version (eg. tagname {\emph{v.0.8}})} \tn 
% Row Count 34 (+ 7)
\end{tabularx}
\par\addvspace{1.3em}

\vfill
\columnbreak
\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Things that might be useful (cont)}}  \tn
% Row 8
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{How to prevent Git from committing certain files?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}If the rule should apply to every developer create a file `.gitignore` in the repository and write in each line a pattern that should be excluded. Commit the file.\{\{nl\}\}Example: *.tmp.\{\{nl\}\}To exclude it locally, change the file `.git/info/exclude` in your repository} \tn 
% Row Count 7 (+ 7)
% Row 9
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{These 40 character {\emph{\$IDs}} in the log are too long.} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}In order to refer to a ID, you only have to provide as many characters as necessary to be unique in your repository. But at least 4 characters.} \tn 
% Row Count 12 (+ 5)
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Resolving Conflicts}}  \tn
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{1. Run `{\bf{git status}}` to see the files where the conflict occurs. \newline % Row Count 2 (+ 2)
2. Open the file that was changed in both branches with your editor. \newline % Row Count 4 (+ 2)
3. Look for passages that look like\{\{nl\}\} \newline % Row Count 5 (+ 1)
`\textless{}\textless{}\textless{}\textless{}\textless{}\textless{}\textless{} HEAD` \newline % Row Count 6 (+ 1)
`    command1` \newline % Row Count 7 (+ 1)
`    command2` \newline % Row Count 8 (+ 1)
`=======` \newline % Row Count 9 (+ 1)
`    command3` \newline % Row Count 10 (+ 1)
`\textgreater{}\textgreater{}\textgreater{}\textgreater{}\textgreater{}\textgreater{}\textgreater{} higherbranch`\{\{nl\}\} \newline % Row Count 11 (+ 1)
4. Decide how the file should look like. In this example you might want to have all 3 commands in the merged result or only one of them. \newline % Row Count 14 (+ 3)
5. Edit the file in a way that the result makes sense. Delete all lines that were introduced by Git. \newline % Row Count 17 (+ 3)
6. Save it. Add it to the index via `{\bf{git add}} {\emph{\$filename}}` and run {\bf{git status}} again. \newline % Row Count 19 (+ 2)
7. Edit all files with conflicts until it says all conflicts are resolved. You can finish it via `{\bf{git commit}}`% Row Count 22 (+ 3)
} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{There are also tools available that help you in comparing the different versions. Use `{\bf{git mergetool}} -{}-tool-help` to get a list of all available tools. Run `{\bf{git mergetool}} -{}-tool={\emph{\$toolname}}` to use it for resolving your conflict.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Basic workflow}}  \tn
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{1. Check if you're in the right branch to work in with `{\bf{git branch}}`. \newline % Row Count 2 (+ 2)
2. Get the most recent changes from the remote repository with `{\bf{git pull}}`. \newline % Row Count 4 (+ 2)
3. Make your changes. \newline % Row Count 5 (+ 1)
4. Before adding  the files with `{\bf{git add}} {\emph{\$filename}}` you might want to check what changes you made in each file via `{\bf{git diff}} {\emph{\$filename}}`. \newline % Row Count 8 (+ 3)
5. Use `{\bf{git status}}` to verify if all changed files you want to commit are added to the index. \newline % Row Count 10 (+ 2)
6. If you want to check again what changes exactly you're going to submit, use `{\bf{git diff}} -{}-cached` to see them all. \newline % Row Count 13 (+ 3)
7. Everything is fine? Use `{\bf{git pull}}` a last time for the case that someone submitted faster than you. \newline % Row Count 16 (+ 3)
8. Finally use `{\bf{git commit}}` to open an editor to provide a helpful commit message that describes your changes. \newline % Row Count 19 (+ 3)
9. Publish your changes that everybody can see them with `{\bf{git push}}`% Row Count 21 (+ 2)
} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Working with branches}}  \tn
% Row 0
\SetRowColor{LightBackground}
`{\bf{git branch}} {\emph{\$branchname}}` & Creates a new branch with the name {\emph{\$branchname}} from the current position. \tn 
% Row Count 4 (+ 4)
% Row 1
\SetRowColor{white}
`{\bf{git checkout}} {\emph{\$branchname}}` & Change to branch {\emph{\$branchname}} \tn 
% Row Count 6 (+ 2)
% Row 2
\SetRowColor{LightBackground}
`{\bf{git checkout}} -b {\emph{\$branchname}}` & Creates branch {\emph{\$branchname}} and switches directly to it \tn 
% Row Count 9 (+ 3)
% Row 3
\SetRowColor{white}
`{\bf{git merge}} {\emph{\$otherbranch}}` & Merges {\emph{\$otherbranch}} to the current positon \tn 
% Row Count 12 (+ 3)
% Row 4
\SetRowColor{LightBackground}
`{\bf{git merge}} -{}-abort` & Aborts a merge in case of a conflict \tn 
% Row Count 14 (+ 2)
% Row 5
\SetRowColor{white}
`{\bf{git stash}}` & Saves your current state \tn 
% Row Count 16 (+ 2)
% Row 6
\SetRowColor{LightBackground}
`{\bf{git stash}} apply` & Restores the stashed state. \tn 
% Row Count 18 (+ 2)
% Row 7
\SetRowColor{white}
`{\bf{git stash}} -{}-help` & More information incl. options {\emph{list}}, {\emph{drop}}, {\emph{pop}} \tn 
% Row Count 21 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{8.4cm}}{`{\bf{git stash}}` is useful when you want to change your branch (for example to fix something important) but don't want to commit your current work already. \newline When you return use `{\bf{git stash}} -{}-apply` to continue your work}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Working with branches step-by-step}}  \tn
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{1. List all available branches with `{\bf{git branch}} -a` \newline % Row Count 2 (+ 2)
2. If you're not in the branch from where you want to start your development, switch to it via `{\bf{git checkout}} {\emph{\$branchname}}` \newline % Row Count 5 (+ 3)
3.  You want to work on a issue or a feature concerning this branch? Create your sub-branch via `{\bf{git checkout}} -b {\emph{\$yourbranchname}}`. Please follow naming conventions for {\emph{\$yourbranchname}} if your team agreed on any. \newline % Row Count 10 (+ 5)
4. Do your changes, commit.  \newline % Row Count 11 (+ 1)
5. Optionally, if your separate development takes a long time, consider to merge changes from the higher branch from time to time with `{\bf{git merge}} {\emph{\$higherbranch}}` in order to reduce the number of possible conflicts at the end. Note that you have to use `{\bf{git pull}}` inside of {\emph{\$higherbranch}}` before you get the most recent changes. \newline % Row Count 18 (+ 7)
6. At the end of your development merge the changes that were made in the meantime from the higher-branch as described in step 5. \newline % Row Count 21 (+ 3)
7. In the case of merge conflicts, solve them. Give attention to the messages in `{\bf{git status}}` \newline % Row Count 23 (+ 2)
8. Check again if everything was committed. Test your feature. \newline % Row Count 25 (+ 2)
9. If you're confident that everything is correct, go to the next higher branch (where you want to have your development included) via `{\bf{git checkout}} {\emph{\$higherbranch}}` and merge your feature with `{\bf{git merge}} {\emph{\$yourbranchname}}`. \newline % Row Count 30 (+ 5)
} \tn 
\end{tabularx}
\par\addvspace{1.3em}

\vfill
\columnbreak
\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Working with branches step-by-step (cont)}}  \tn
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{10. There shouldn't be any conflicts in the last step. If there are, it means that someone published changes in the meantime. Use `{\bf{git merge}} -{}-abort`, switch back to your branch and repeat the steps beginning from 6.% Row Count 5 (+ 5)
} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{Note: It is not the only way how to work with branches. It is also not the most elegant way but should be relatively safe with regard to possible errors.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Undo and rewriting history}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{How to add an additional file to the last commit or re-edit the commit message?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}If you haven't pushed the commit yet do the following: Add the file you forgot to the index and use `{\bf{git commit}} -{}-amend`. In the case you only want to change the message, just type the command without adding a file to the index.\{\{nl\}\}Alternative: Use `{\bf{git reset}} -{}-soft HEAD\textasciicircum{}`. It sets your local repository back by one commit while leaving the working directory unchanged. You can start from there to add again files and to commit again.} \tn 
% Row Count 12 (+ 12)
% Row 1
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{How to delete my last commit (locally)?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}In the case you haven't pushed it yet, you can use: `{\bf{git reset}} -{}-hard HEAD\textasciicircum{}` to reset your local repository and your working directory to the commit before.\{\{nl\}\} For the case you already published it, use the command `{\bf{git revert}} HEAD` to create an anti-commit for the last commit. `{\bf{git revert}}` works also with older commits. In this case provide the {\emph{\$ID}} instead of HEAD.} \tn 
% Row Count 22 (+ 10)
% Row 2
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{I haven't pushed the last 4 commits yet and I want to change them into two bigger ones and to adjust the messages. How can I do it?} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Use `{\bf{git rebase}} -{}-interactive HEAD\textasciicircum{}4`. Change the letters in front of the presented commits in the way you want to change them.} \tn 
% Row Count 28 (+ 6)
% Row 3
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{I lost something.} \tn 
\mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Use `{\bf{git reflog}}`. You might be able to restore it. (Checkout to an earlier reflog entry or cherry-pick it again)} \tn 
% Row Count 32 (+ 4)
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{{\bf{Warning:}} Only change commit messages or change history in the case that they are {\bf{NOT published}} yet (via git push) or you're completely sure that nobody based his work on it.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Merged subbranch}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/schmidt7_1473675057_basic-merging-2.png}}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{From the (online-)book ProGit \seqsplit{(https://git-scm.com/doc).} Example of a merged issue branch.}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}


% That's all folks
\end{multicols*}

\end{document}