Commit 9bec0a85 authored by Mihai's avatar Mihai

Update to commit graph handouts

parent e1340367
\documentclass{article}
\providecommand{\handoutsTitle}{\vspace{0.5cm}Combining changes by merging}
\providecommand{\handoutsTitle}{\vspace{0.5cm}The git commit graph}
\usepackage{handouts}
\input{../shared/shared}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{graphicx}
\begin{document}
\makeHeader
\subsubsection*{Fast-forward merging}
Edit again a file from the GitLab interface and run a \lstinline{git fetch} command on your local machine.
\bigskip
\section{General questions}
\begin{enumerate}
\item How do you check your local git repository state since your last commit?
\vspace{-0.2cm}
\begin{multicols}{3}
\begin{enumerate}[label=(\alph*)]
\item git state
\item git repository
\item git commit
\item git status
\item git show
\item git log
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item A branch is:
\vspace{-0.2cm}
\begin{multicols}{3}
\begin{enumerate}[label=(\alph*)]
\item a file
\item a merge conflict
\item a pointer to a commit
\item always a problem
\item to enable collaboration
\item none of the above
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item What command is used in joining two or more development histories together:
\vspace{-0.2cm}
\begin{multicols}{3}
\begin{enumerate}[label=(\alph*)]
\item join
\item combine
\item merge
\item pull
\item fork
\item intersect
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item What command displays the branches list:
\vspace{-0.2cm}
\begin{multicols}{3}
\begin{enumerate}[label=(\alph*)]
\item show-branch
\item merge
\item display
\item branch
\item list
\item clone
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item Which of the following creates a new branch called \colorbox{gray!20}{brand\_new} and also checks it out?
\vspace{-0.2cm}
\begin{multicols}{3}
\begin{enumerate}[label=(\alph*)]
\item git branch -c branch\_new
\item git new branch branch\_new
\item git status brand\_new
\item git checkout -b brand\_new
\item git commit brand\_mew
\item none of the above
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item In order to merge a branch into \colorbox{gray!20}{master} do we have to add and commit changes to that branch first?
\vspace{-0.2cm}
\begin{multicols}{2}
\begin{enumerate}[label=(\alph*)]
\item Yes
\item No
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item If we want to merge \colorbox{gray!20}{brand\_new} into \colorbox{gray!20}{master}, which branch should be checked out when we run the command \colorbox{gray!20}{git merge brand\_new}?
\vspace{-0.2cm}
\begin{multicols}{2}
\begin{enumerate}[label=(\alph*)]
\item brand\_new
\item any branch
\item master
\item none of the above
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item Which of the following commands will delete the branch \colorbox{gray!20}{brand\_new}:
\vspace{-0.2cm}
\begin{multicols}{2}
\begin{enumerate}[label=(\alph*)]
\item it is impossible to delete a branch
\item git delete branch brand\_new
\item git head -d brand\_new
\item git branch -d brand\_new
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\item You are in a detached head state when:
\vspace{-0.2cm}
\begin{multicols}{2}
\begin{enumerate}[label=(\alph*)]
\item there is no head
\item the head points to the master branch
\item the head points to a commit
\item the head points to a different branch then the master branch
\end{enumerate}
\end{multicols}
\vspace{-0.3cm}
\end{enumerate}
\section{Inspecting the commit graph}
In the following you will work with the repository present in \colorbox{gray!20}{$\sim$/practice\_repo}.
Please navigate to that directory and try to use the commands presented during the lecture (with their options accordingly) to perform the following tasks and answer the corresponding questions.
\begin{enumerate}
\item How many branches are there?
\vspace{-0.2cm}
\begin{multicols}{2}
\begin{enumerate}[label=(\alph*)]
\item none
\item only the master branch
\item 4
\item 3
\end{enumerate}
\end{multicols}
\item The commit graph looks like:
\vspace{-0.2cm}
\begin{center}
\includegraphics[width=\textwidth]{images/initial_practical_graph.pdf}
\end{center}
\item Merge branch \colorbox{gray!20}{documentation} into \colorbox{gray!20}{master}. What kind of merge was performed?
\vspace{-0.2cm}
\begin{multicols}{2}
\begin{enumerate}[label=(\alph*)]
\item fast-forward
\item try-and-leave
\item three-way
\item advanced
\end{enumerate}
\end{multicols}
\item Merge branch \colorbox{gray!20}{data} into \colorbox{gray!20}{master}. What kind of merge was performed?
\vspace{-0.2cm}
\begin{multicols}{2}
\begin{enumerate}[label=(\alph*)]
\item fast-forward
\item three-way
\item try-and-leave
\item advanced
\end{enumerate}
\end{multicols}
\end{enumerate}
\section{More commit graph manipulation}
You have already performed some merging in the previous section, but the repository state was beforehand prepared for you.
Next, you will make some file changes and manipulate the commit graph even further.
\subsection{Fast-forward merging}
Checkout branch \colorbox{gray!20}{data} and create a new branch called \colorbox{gray!20}{data-europe}.
Edit the \colorbox{gray!20}{capitals.txt} file by adding at the end some more european countries together with their capitals.
Checkout branch \colorbox{gray!20}{data} and perform a \textbf{fast-forward merge} of the \colorbox{gray!20}{data-europe} branch into \colorbox{gray!20}{data} branch.
\subsection{Three-way merging}
Branch \colorbox{gray!20}{data} should be checkedout. Correct the capital USA to Washington D.C. in the capitals.txt file and commit.
Checkout branch \colorbox{gray!20}{data-europe}. Add Paris as capital of France at the end of the file capitals.txt and commit.
Checkout branch \colorbox{gray!20}{data} and merge into it branch \colorbox{gray!20}{data-europe}.
A three-way merge without conflicts should have been performed.
\subsection{Resolving a merge conflict}
Checkout branch \colorbox{gray!20}{data}. Add Moscow as capital of Russia at the end of the file capitals.txt and commit.
Inspect the \textbf{commit graph} with \lstinline{git log}. Make sure you utilize the options described during the lecture.
\bigskip
Checkout branch \colorbox{gray!20}{data-europe} and add Madrid as the capital of Spain at the of the file capitals.txt and commit.
Perform a \textbf{fast-forward merge} of the \textbf{origin master} branch into your \textbf{local master} branch.
\bigskip
Checkout branch \colorbox{gray!20}{data} and merge into it branch \colorbox{gray!20}{data-europe}.
\subsubsection*{A three-way merge with no conflicts}
The previous section produced a fast-forward merge. In the following you will perform a \textbf{three-way merge}.
A merge conflict should have occurred. Solve it and commit.
\begin{itemize}
\item \emph{Question:} Can you think of a way to get a three-way merge without conflicts?
\end{itemize}
\subsection{Branch deletion}
Edit the same file on both your GitLab and local repositories (make sure that different lines are changed).
\bigskip
Delete branch \colorbox{gray!20}{data-europe}.
Run \lstinline{git fetch} on your local repository.
Merge branch \colorbox{gray!20}{data} into \colorbox{gray!20}{master}.
\begin{itemize}
\item \emph{Question:} What does the commit graph of you repository look
like now? Can you draw it on paper?
\end{itemize}
Delete branch \colorbox{gray!20}{data}
Perform a \textbf{three-way merge} and \textbf{push} to the GitLab remote repository.
\bigskip
\section{Solutions}
\begin{multicols}{6}
\begin{itemize}
\item 1.1 - d
\item 1.2 - c
\item 1.3 - c
\item 1.4 - d
\item 1.5 - d
\item 1.6 - a
\item 1.7 - c
\item 1.8 - d
\item 1.9 - d
\item 2.1 -
\item 2.2 -
\end{itemize}
\end{multicols}
\subsubsection*{Resolving a merge conflict}
Now do the same thing again (a three-way merge), but in such a way that the merge
step will result in a merge conflict. Resolve the conflict in a way you feel
is appropriate.
\end{document}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment