From efa87d5cc70cf95055319a18c3b878fc5c965fe2 Mon Sep 17 00:00:00 2001 From: mlefter Date: Thu, 22 Mar 2018 14:50:49 +0100 Subject: [PATCH] Moved common parts to shared and started basics update --- basics/basics.tex | 117 ++++++++----- basics/images/git_areas.svg | 321 ++++++++++++++++++++++++++++++++++ commit_graph/commit_graph.tex | 31 +--- shared/shared.tex | 30 ++++ 4 files changed, 433 insertions(+), 66 deletions(-) create mode 100644 basics/images/git_areas.svg diff --git a/basics/basics.tex b/basics/basics.tex index 2d3a4f5..5abc94b 100644 --- a/basics/basics.tex +++ b/basics/basics.tex @@ -2,13 +2,13 @@ \input{../shared/shared.tex} -\author{Jeroen F.J. Laros} +\author{} \title{\courseTitle} \providecommand{\mySubTitle}{Git Basics} \providecommand{\myConference}{\courseTitle} \providecommand{\myGroup}{} \providecommand{\myDepartment}{Department of Human Genetics} -\providecommand{\myCenter}{Center for Human and Clinical Genetics} +\providecommand{\myCenter}{} \usetheme{lumc} @@ -18,62 +18,97 @@ %\renewcommand{\pause}{} % Make the title slide. -\makeTitleSlide{\includegraphics[width=3.5cm]{git_logo}} +\makeTitleSlide{\includegraphics[width=3.5cm]{../shared/git_logo.pdf}} % First page of the presentation. -\section{Initialisation} -\subsection{Starting a project} +\section{Starting a project} +\subsection{You can either} \begin{pframe} - Creating a new repository is easy. You do not need a server, no registration, - etc. - \begin{lstlisting}[language=none, caption=Make a new repository.] - $ cd ~/projects - $ git init - Initialized empty Git repository in /.git/ - \end{lstlisting} + 1. Start from scratch on your own: + \vspace{-0.3cm} + \begin{framed} + \prompt\ \cmd{mkdir}\ \cmdarg{my\_project}\\ + \prompt\ \cmd{cd}\ \cmdarg{my\_project}\\ + \prompt\ \gitcmd\ \cmd{init}\\ + \cliout{Initialized empty Git repository in \{current-directory\}\/.git\/} + \end{framed} \pause - Or you can ``clone'' an existing repository. - \begin{lstlisting}[language=none, caption=Clone an existing repository.] - $ git clone - \end{lstlisting} + 2. Or you can \cmd{clone} an existing remote (or local) repository: + \vspace{-0.3cm} + \begin{framed} + \prompt\ \gitcmd\ \cmd{clone}\ \cmdarg{\}\\ + \cliout{Cloning into \{repo-name\} ...} + \end{framed} \end{pframe} +\subsection{Where does git store its repository information?} \begin{pframe} You can see a hidden directory in a Git repository. - \begin{lstlisting}[language=none, caption=A hidden directory is added.] - $ ls -a - . .. .git - \end{lstlisting} + \vspace{-0.3cm} + \begin{framed} + \prompt\ \cmd{ls}\ \cmdopt{-a}\\ + \cliout{. .. .git} + \end{framed} + + This is where git stores the files necessary to track your progress. You + rarely need to edit the contents of this directory. + \bigskip - This directory contains almost everything that Git stores and manipulates. + \important{Removing this directory means removing your repository!} \end{pframe} -\section{Manipulation} -\subsection{Local operations} +\section{Git Operations} \begin{pframe} - \begin{figure}[] - \begin{center} - \includegraphics[height=0.7\textheight]{18333fig0106-tn} - \end{center} - \caption{Working directory, staging area, and Git directory.} - \end{figure} + \vspace{-0.9cm} + Operations can be local or remote.\\ + Most importantly, they track files around these three areas + \footnote[1]{\scriptsize{Adapted from + \href{http://git-scm.com/book/en/v2/Getting-Started-Git-Basics} + {Pro Git Book}.}}: + \begin{center} + \includegraphics[width=0.7\textwidth]{images/git_areas.pdf}\\ + \end{center} \end{pframe} -\subsection{Checking the status of your files} +\subsection{Prelude: quick setup} \begin{pframe} - \begin{lstlisting}[language=none, caption=Check status.] - $ git status - nothing to commit (working directory clean) - \end{lstlisting} + If you have never used \gitcmd\ before you need to tell it who you are. This + information is saved in \cmdarg{.gitconfig}\ and used to mark each commit. + \vspace{-0.4cm} + \begin{framed} + \prompt\ \gitcmd\ \cmd{config}\ \cmdopt{--global user.name}\ + \cmdarg{\{your-name-or-nick-name\}}\\ + \prompt\ \gitcmd\ \cmd{config}\ \cmdopt{--global user.email}\ + \cmdarg{\{your-email-address\}} + \end{framed} + \pause + \vspace{-0.2cm} + + Local configuration for each repository is possible as well. + \vspace{-0.4cm} + \begin{framed} + \prompt\ \gitcmd\ \cmd{config}\ \cmdopt{--local user.name}\ + \cmdarg{\{your-name-or-nick-name\}}\\ + \prompt\ \gitcmd\ \cmd{config}\ \cmdopt{--local user.email}\ + \cmdarg{\{your-email-address\}} + \end{framed} + \vspace{-0.2cm} + \pause - ``\lstinline{git status}'' can tell you whether your files are: - \begin{itemize} - \item Untracked. - \item Unmodified. - \item Modified. - \item Staged. - \end{itemize} + You would like colored output? + \vspace{-0.4cm} + \begin{framed} + \prompt\ \gitcmd\ \cmd{config}\ \cmdopt{--global color.ui}\ \cmdarg{auto} + \end{framed} +\end{pframe} + +\subsection{Checking the status of your files} +\begin{pframe} + \begin{framed} + \prompt\ \gitcmd\ \cmd{status}\\ + \cliout{nothing to commit (working directory clean)} + \end{framed} \end{pframe} \begin{pframe} diff --git a/basics/images/git_areas.svg b/basics/images/git_areas.svg new file mode 100644 index 0000000..be6a3e1 --- /dev/null +++ b/basics/images/git_areas.svg @@ -0,0 +1,321 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + WorkingDirectory + + + + StagingArea + + + + .git directory(repository) + + + + + + + + Checkout + + Stage fixes + + Commit + where files aremarked for saving + where history issaved (invisible) + where you modifyyour files + + + + + diff --git a/commit_graph/commit_graph.tex b/commit_graph/commit_graph.tex index 14f5e2b..58d2edd 100644 --- a/commit_graph/commit_graph.tex +++ b/commit_graph/commit_graph.tex @@ -12,25 +12,6 @@ \providecommand{\myDepartment}{Department of Human Genetics} \providecommand{\myCenter}{Center for Human and Clinical Genetics} -\definecolor{cblack}{rgb}{0,0,0} -\definecolor{cwhite}{rgb}{1,1,1} -\definecolor{command-color}{rgb}{0,0.5,0} -\definecolor{git-color}{rgb}{0.94,0.23,0.18} -\definecolor{option-color}{rgb}{0.9,0.2,0.11} -\definecolor{argument-color}{rgb}{0.11,0.27,0.7} -\definecolor{pattern-color}{rgb}{0,0.5,0.5} -\definecolor{wildcard-color}{rgb}{0.75,0.3,0} -\definecolor{cli-text}{rgb}{0.15,0.15,0.15} -\definecolor{important-note}{rgb}{0.69,0.13,0.13} -\definecolor{redirection}{rgb}{0.99,0.13,0.13} -\definecolor{shadecolor}{rgb}{0.9,0.9,0.9} -\definecolor{one-dot}{rgb}{0.9,0.2,0.0} -\definecolor{two-dots}{rgb}{0.11,0.11,0.8} -\definecolor{slash}{rgb}{0.3,0.3,0.3} - -\definecolor{head}{HTML}{B22222} -\definecolor{branch}{HTML}{20b2aa} -\definecolor{commit-id}{HTML}{b8860b} \usetheme{lumc} @@ -297,7 +278,7 @@ Creates branch \textcolor{branch}{\lstinline{lib}} at \textcolor{head}{\lstinline{HEAD}}. \pause \medskip - + How can I see that it worked? \pause \vspace{-0.3cm} @@ -311,17 +292,17 @@ \end{framed} \vspace{-0.2cm} \pause - + How can I switch to the new \textcolor{branch}{\lstinline{lib}} branch? \end{pframe} - + \begin{pframe} \begin{framed} \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{checkout}} \textcolor{argument-color}{\lstinline{lib}}\\ \lstinline{Switched to branch '}\textcolor{branch}{\lstinline{lib}}\lstinline{'} \end{framed} \end{pframe} - + \begin{pframe} For Git pro's, in one command: \begin{framed} @@ -441,7 +422,7 @@ \begin{pframe} Make sure that the working directory is clean before merging. \medskip - + Otherwise: \vspace{-0.3cm} \begin{framed} @@ -513,7 +494,7 @@ \lstinline{* }\textcolor{commit-id}{\lstinline{5edaf08}}\lstinline{ (}\textcolor{branch}{\lstinline{hue}}\lstinline{) State character ...}\\ \lstinline{| * }\textcolor{commit-id}{\lstinline{f1ef19c}}\lstinline{ (}\textcolor{head}{\lstinline{HEAD}}\lstinline{, }\textcolor{branch}{\lstinline{master}}\lstinline{) State character ...}\\ \lstinline{|/}\\ - \lstinline{* }\textcolor{commit-id}{\lstinline{1f6d2ab}}\lstinline{ Initial commit} + \lstinline{* }\textcolor{commit-id}{\lstinline{1f6d2ab}}\lstinline{ Initial commit} \end{framed} We'd like to merge branch \textcolor{branch}{\lstinline{hue}} into \textcolor{branch}{\lstinline{master}}. diff --git a/shared/shared.tex b/shared/shared.tex index 83965c2..6fed5cc 100644 --- a/shared/shared.tex +++ b/shared/shared.tex @@ -1,3 +1,5 @@ +\usepackage{framed} + \providecommand{\courseTitle}{Code and data management with Git} \providecommand{\myDate}{22-11-2017} \providecommand{\acknowledgements}{ @@ -6,3 +8,31 @@ Szymon Kie{\l}basa\\ Jeroen Laros\\ } + +\definecolor{cblack}{rgb}{0,0,0} +\definecolor{cwhite}{rgb}{1,1,1} +\definecolor{command-color}{rgb}{0,0.5,0} +\definecolor{git-color}{rgb}{0.94,0.23,0.18} +\definecolor{option-color}{HTML}{483d8b} +\definecolor{argument-color}{rgb}{0.11,0.27,0.7} +\definecolor{pattern-color}{rgb}{0,0.5,0.5} +\definecolor{wildcard-color}{rgb}{0.75,0.3,0} +\definecolor{cli-text}{rgb}{0.15,0.15,0.15} +\definecolor{important-note}{rgb}{0.69,0.13,0.13} +\definecolor{redirection}{rgb}{0.99,0.13,0.13} +\definecolor{shadecolor}{rgb}{0.9,0.9,0.9} +\definecolor{one-dot}{rgb}{0.9,0.2,0.0} +\definecolor{two-dots}{rgb}{0.11,0.11,0.8} +\definecolor{slash}{rgb}{0.3,0.3,0.3} + +\definecolor{head}{HTML}{B22222} +\definecolor{branch}{HTML}{20b2aa} +\definecolor{commit-id}{HTML}{b8860b} + +\newcommand{\gitcmd}{\textcolor{git-color}{\lstinline{git}}} +\newcommand{\prompt}{\lstinline{$}} +\newcommand{\cmd}[1]{\textcolor{command-color}{\lstinline{#1}}} +\newcommand{\cmdarg}[1]{\textcolor{argument-color}{\lstinline{#1}}} +\newcommand{\cmdopt}[1]{\textcolor{option-color}{\lstinline{#1}}} +\newcommand{\cliout}[1]{\textcolor{cli-text}{\lstinline{#1}}} +\newcommand{\important}[1]{\textbf{\textcolor{important-note}{#1}}} -- 2.18.1