\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{Ariel Gonzalez (ArielJGS)} \pdfinfo{ /Title (git-cheat-sheet.pdf) /Creator (Cheatography) /Author (Ariel Gonzalez (ArielJGS)) /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}{Ariel Gonzalez (ArielJGS)} via \textcolor{DarkBackground}{\uline{cheatography.com/159091/cs/33552/}}} \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}Ariel Gonzalez (ArielJGS) \\ \uline{cheatography.com/arieljgs} \\ \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 7th August, 2022.\\ 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*}{3} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Initial commands}} \tn % Row 0 \SetRowColor{LightBackground} git -{}-version & Check yout git version \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git config -{}-global user.name "Your name" & Configure your name as default \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} git config -{}-global user.email "Your email" & Configure your email as default \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} git config -{}-global core.editor "code -{}-wait" & Configure a default editor, here vscode is being used as default \tn % Row Count 12 (+ 4) % Row 4 \SetRowColor{LightBackground} git config -{}-global -e & Open and edit your configuration settings \tn % Row Count 15 (+ 3) % Row 5 \SetRowColor{white} git config -{}-global core.autocrlf "input/true" & How git should handle end of lines \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Viewing staged and unstaged changes}} \tn % Row 0 \SetRowColor{LightBackground} git diff -{}-staged & Staging area changes that are going to the next commit \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Viewing history}} \tn % Row 0 \SetRowColor{LightBackground} git log & Show history of your repository \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git log -{}-oneline & Short history output \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} git log -{}-oneline -{}-reverse & Show history from the first commit \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} git log -{}-oneline -{}-stat & Show all the files that have been changed in each commit \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} git log -{}-stat & More details about each commit \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} git log -{}-oneline -{}-patch & Full changes details in each commit \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} git log -{}-oneline -{}-author="Name" & Commits from a given author \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} git log -{}-oneline -{}-after|-{}-before="Date | Relative date" & Commits from a given date \tn % Row Count 17 (+ 3) % Row 8 \SetRowColor{LightBackground} git log -{}-oneline -{}-grep="Sometext" & Commits that contain the specified text, case sensitive \tn % Row Count 20 (+ 3) % Row 9 \SetRowColor{white} git log -{}-oneline -S"Sometext" & Find all a commits that have added or removed the specified text \tn % Row Count 24 (+ 4) % Row 10 \SetRowColor{LightBackground} git log -{}-oneline -S"Sometext" -{}-patch & Mixed with patch to show full details about the commit \tn % Row Count 27 (+ 3) % Row 11 \SetRowColor{white} git log -{}-oneline hash..hash & Filter commits by a given range of commits \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Viewing history (cont)}} \tn % Row 12 \SetRowColor{LightBackground} git log -{}-oneline -{}- file.txt & Find commits that have modified a given file \tn % Row Count 3 (+ 3) % Row 13 \SetRowColor{white} git log -{}-oneline -{}-stat -{}- file.txt & Short output for changes over a given file \tn % Row Count 6 (+ 3) % Row 14 \SetRowColor{LightBackground} git log -{}-oneline -{}-patch -{}- file.txt & Full changes over a given file \tn % Row Count 8 (+ 2) % Row 15 \SetRowColor{white} git log -{}-pretty=format:"Your format" & Customize the way you see output, then use alias for ease of use \tn % Row Count 12 (+ 4) % Row 16 \SetRowColor{LightBackground} git config -{}-global alias.youralias "log -{}-pretty=format:'Your format' & Alias example \tn % Row Count 16 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Stashing}} \tn % Row 0 \SetRowColor{LightBackground} git stash push -m "Your message" & Save your changes without committing them if you need to switch to a different branch. Stashing = Saving something in a safe place \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} git stash push -{}-all -m "Your message" & Stashing new untracked files \tn % Row Count 9 (+ 2) % Row 2 \SetRowColor{LightBackground} git stash list & Show a list of stashed files \tn % Row Count 11 (+ 2) % Row 3 \SetRowColor{white} git stash show stash@\{0\} | 0 & Show specific stashed file by its index \tn % Row Count 13 (+ 2) % Row 4 \SetRowColor{LightBackground} git stash apply 0 & Apply this stash to our working directory \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} git stash drop 1 & Remove a specific stash \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} git stash clear & Remove all stashes \tn % Row Count 19 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Viewing changes across commits}} \tn % Row 0 \SetRowColor{LightBackground} git diff HEAD\textasciitilde{}2 HEAD & Show differences between a range of commits \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} git diff HEAD\textasciitilde{}2 HEAD file.txt & Same as above but for a single file \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} git diff HEAD\textasciitilde{}2 HEAD -{}-name-only & Show list of modified files in a given range of commits \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} git diff HEAD\textasciitilde{}2 HEAD -{}-name-status & Show list of files and the type of change for each one \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{About merging}} \tn % Row 0 \SetRowColor{LightBackground} Fast-forward & Fast forward merge can be performed when there is a direct linear path from the source branch to the target branch. In fast-forward merge, git simply moves the source branch pointer to the target branch pointer without creating an extra merge commit. \tn % Row Count 11 (+ 11) % Row 1 \SetRowColor{white} Three way merge & Fast-forward merge is not possible if the branches have diverged. Then we need a 3-way merge which uses a dedicated commit to merge two histories or you can say branches. This new commit is based on three different commits, the common ancestor of our branches which includes the before code and the tips of our branches which contains the after code. \tn % Row Count 26 (+ 15) % Row 2 \SetRowColor{LightBackground} Fast-forward controversy & Cons: Pollutes the history, linear history is preferred for some people \tn % Row Count 29 (+ 3) % Row 3 \SetRowColor{white} & Pros: True reflection of history, easier to undo a feature \tn % Row Count 32 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{No fast forward merge}} \tn % Row 0 \SetRowColor{LightBackground} git merge -{}-no-ff bugfix/login-form & Merges the specified branch without using fast forward merge \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} git config -{}-global ff no & Disable fast forward in every repository \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Managing merges}} \tn % Row 0 \SetRowColor{LightBackground} git merge \seqsplit{bugfix/signup-form} & Merges a branch into master \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git log -{}-oneline -{}-all -{}-graph & Shows a graph for easier understanding of merges \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} git branch -{}-merged & View list of branches that have been merged into master, it's safe to delete these branches \tn % Row Count 10 (+ 5) % Row 3 \SetRowColor{white} git branch -d \seqsplit{bugfix/signup-form} & Delete a branch \tn % Row Count 12 (+ 2) % Row 4 \SetRowColor{LightBackground} git branch -{}-no-merged & View list of branches that have not been merged into master \tn % Row Count 15 (+ 3) % Row 5 \SetRowColor{white} git merge -{}-abort & Abort a merge if you run into a conflict that you're not ready to fix \tn % Row Count 19 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Managing your first repository}} \tn % Row 0 \SetRowColor{LightBackground} git init & Initialize your repository \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git status & Get status of your current changes \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} git status -s & Short status information \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} git add \seqsplit{"./file1|file2/*.txt"} & Add files to the staging area for review \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Commiting changes}} \tn % Row 0 \SetRowColor{LightBackground} git commit -m "Your message" & Commit changes from your staging area and add message \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} git commit & Add a longer message for bigger or more detailed descriptions \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} git commit -am "Your message" & Skip the staging area and commit changes directly \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} Tips & Commits shouldn't be too big or too short, also use present or past tense verbs but stick to only one and be clear with your messages \tn % Row Count 15 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Restoring files}} \tn % Row 0 \SetRowColor{LightBackground} git restore -{}-staged file.txt & Unstage or restore a file in the staging area taking the content from the latest commit \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} git restore -{}-source=hash file.txt | HEAD\textasciitilde{}1 file.txt & Restore a file to an earlier version \tn % Row Count 8 (+ 3) % Row 2 \SetRowColor{LightBackground} git clean -fd & Discard local changes for new or modified files and directories \tn % Row Count 12 (+ 4) % Row 3 \SetRowColor{white} Note & The restore command takes a copy from the next environment, for example, the working directory takes a copy from the staging area and the staging area takes it from the latest commit \tn % Row Count 22 (+ 10) % Row 4 \SetRowColor{LightBackground} git checkout hash file.txt & Restore file from a given commit hash \tn % Row Count 24 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Viewing a commit}} \tn % Row 0 \SetRowColor{LightBackground} git show "hash | HEAD\textasciitilde{}1" & Show what was changed in a given commit \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git show \seqsplit{"hash:files/file1.txt} | HEAD\textasciitilde{}1:files/file1.txt" & Show the content of a file in a given commit \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} git ls-tree "hash | HEAD\textasciitilde{}1" & Show all files in a given commit \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} git show HEAD\textasciitilde{}1 -{}-name-only & Show files that have been modified in a given commit \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} git show HEAD\textasciitilde{}1 -{}-name-status & Show files + status: added, deleted, modifiedetc... \tn % Row Count 13 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Blaming}} \tn % Row 0 \SetRowColor{LightBackground} git blame file.txt & Show who modified a given file \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git blame -e file.txt & With email \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} git blame -e -L 1,3 file.txt & With a range of specific lines \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Working with branches}} \tn % Row 0 \SetRowColor{LightBackground} git branch & Show a list of existing branches \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git branch name & Create a new branch with a given name \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} git switch name & Switch to a different branch \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} git switch -C name & Create and switch to a branch \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} git branch -m name bugfix/signup-form & Change the name of a branch \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} git diff \seqsplit{master..bugfix/signup-form} & See differences between branches \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} git diff bugfix/signup-form & If you're already in master there is no need to specify it \tn % Row Count 15 (+ 3) % Row 7 \SetRowColor{white} git branch -d bugfix/signup-form & Delete a branch after it has served its purpose \tn % Row Count 18 (+ 3) % Row 8 \SetRowColor{LightBackground} git branch -D bugfix/signup-form & Force deletion if you want to discard any changes made in this branch \tn % Row Count 22 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Removing files}} \tn % Row 0 \SetRowColor{LightBackground} git ls-files & Show current files in your staging area \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git rm \seqsplit{"./file1|file2/*.txt"} & Remove files from the current directory and staging area at the same time \tn % Row Count 6 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Renaming or Moving files}} \tn % Row 0 \SetRowColor{LightBackground} git mv oldname.txt newname.txt & Move or rename files in the working directory and staging area at the same time \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Ignore files}} \tn % Row 0 \SetRowColor{LightBackground} Create .gitignore & Include any files that you want to ignore here, examples: logs/ | main.log | *.log \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Note & This only ignores files or directories if they have not been committed in the repository before \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} git rm -{}-cached -r logs/ & Remove directory that was already committed by accident to start ignoring it with .gitignore \tn % Row Count 12 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.84149 cm} x{3.13551 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Checking out a commit}} \tn % Row 0 \SetRowColor{LightBackground} git checkout "hash" & Go back in time and check a previous commit, this will show the state of every file as it was at that point in time \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} git log -{}-oneline -{}-all & You will need to add the parameter -{}-all to show every commit when you're checking an old commit \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} git checkout master & Go back to your latest commit \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Finding contributors using shortlog}} \tn % Row 0 \SetRowColor{LightBackground} git shortlog & Show people that have contributed to the project \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} git shortlog -n & Sorted by number of commits per author \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} git shortlog -n -s & Suppress the commit messages \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} git shortlog -n -s -e & Show email address \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} git shortlog -n -s -e -{}-before="" -{}-after="" & Show contributors for a given date \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Tagging}} \tn % Row 0 \SetRowColor{LightBackground} git tag & Show a list of existing tags \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} git tag -n & With their messages \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} git tag v1.0 & Create a tag for the current latest commit \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} git tag v1.0 hash & Create a tag for a specific commit \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} git checkout v1.0 & Then you can reference a commit by its tag \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} Note & Git supports two types of tags: lightweight and annotated. A lightweight tag is very much like a branch that doesn't change — it's just a pointer to a specific commit. Annotated tags, however, are stored as full objects in the Git database. They're checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It's generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don't want to keep the other information, lightweight tags are available too. \tn % Row Count 38 (+ 29) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Tagging (cont)}} \tn % Row 6 \SetRowColor{LightBackground} git tag -a v1.1 -m "Your message" & Create an annotated tag and provide a message to it \tn % Row Count 3 (+ 3) % Row 7 \SetRowColor{white} git show v1.1 & Show commit by its tag \tn % Row Count 4 (+ 1) % Row 8 \SetRowColor{LightBackground} git tag -d v1.1 & Delete a tag \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}