merging_handouts.tex 2.28 KB
 Vermaat committed Nov 30, 2015 1 2 3 4 5 6 7 8 9 10 11 \documentclass{article} \usepackage{fullpage} \frenchspacing \setlength{\parindent}{0pt} \pagestyle{empty} \begin{document} \begin{center} {\bf Git Introduction Course}  Vermaat committed Dec 01, 2015 12 Combining changes by merging practical.  Vermaat committed Nov 30, 2015 13 14 15 \end{center} \bigskip  Vermaat committed Dec 01, 2015 16 17 18 19 \subsubsection*{Setting the stage.} In this practical, you'll work with the repository your neighbour created during the previous practical. We'll refer to this repository as {\bf N}, and to your own repository from the previous practical as {\bf Y}.  Vermaat committed Nov 30, 2015 20 21 22  \bigskip  Vermaat committed Dec 01, 2015 23 24 Clone his or her repository to your local machine. Make sure to do this in a separate directory.  Vermaat committed Nov 30, 2015 25 26 27  \bigskip  Vermaat committed Dec 01, 2015 28 29 30 31 32 33 34 After you and your neighbour both cloned eachother's repositories: \begin{enumerate} \item Add a new commit to repository {\bf Y} on GitLab (so the one your neighbour just cloned). \item Wait for eachother before continuing. \item Update your clone of {\bf N} with \texttt{git fetch}. \end{enumerate}  Vermaat committed Nov 30, 2015 35 36 37  \bigskip  Vermaat committed Dec 01, 2015 38 39 \emph{Question:} What does the commit graph of your repository look like? Can you draw it on paper?  Vermaat committed Nov 30, 2015 40 41 42  \bigskip  Vermaat committed Dec 01, 2015 43 \emph{Hint:} Use \texttt{git log} with the appropriate arguments.  Vermaat committed Nov 30, 2015 44 45 46  \bigskip  Vermaat committed Dec 01, 2015 47 48 As an alternative to \texttt{git log}, you can also try a graphical viewer such as \texttt{gitg} (installed on the course laptops) or \texttt{gitk}.  Vermaat committed Nov 30, 2015 49 50 51  \bigskip  Vermaat committed Dec 01, 2015 52 53 54 \subsubsection*{Fast-forward merging.} Of course we want the nice commit your neighbour just made in our \texttt{master} branch.  Vermaat committed Nov 30, 2015 55 56 57  \bigskip  Vermaat committed Dec 01, 2015 58 Merge the remote \texttt{master} branch into \texttt{master}.  Vermaat committed Nov 30, 2015 59 60 61 62 63 64 65 66 67  \begin{itemize} \item \emph{Question:} What does the commit graph of you repository look like now? \end{itemize} \bigskip \subsubsection*{A three-way merge.}  Vermaat committed Dec 01, 2015 68 The previous section produced a fast-forward merge.  Vermaat committed Nov 30, 2015 69 70 71 72 73 74 75 76 77  \bigskip \begin{itemize} \item \emph{Question:} Can you think of a way to get a three-way merge? \end{itemize} \bigskip  Vermaat committed Dec 01, 2015 78 79 Together with your neighbour, manipulate your repository in such a way that the commit graph contains a merge commit (created by a three-way merge).  Vermaat committed Nov 30, 2015 80 81 82 83 84 85  \begin{itemize} \item \emph{Question:} What does the commit graph of you repository look like now? \end{itemize}  Vermaat committed Dec 01, 2015 86 87 88 89 90 91 92 93 \bigskip \subsubsection*{Resolving a merge conflict.} Now do the same thing again (a three-way merge), but in such a way the merge step will result in a merge conflict. Resolve the conflict in a way you feel is appropriate.  Vermaat committed Nov 30, 2015 94 \end{document}