merging_handouts.tex 2.28 KB
Newer Older
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's avatar
Vermaat committed
12
Combining changes by merging practical.
13
14
15
\end{center}
\bigskip

Vermaat's avatar
Vermaat committed
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}.
20
21
22

\bigskip

Vermaat's avatar
Vermaat committed
23
24
Clone his or her repository to your local machine. Make sure to do this in a
separate directory.
25
26
27

\bigskip

Vermaat's avatar
Vermaat committed
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}
35
36
37

\bigskip

Vermaat's avatar
Vermaat committed
38
39
\emph{Question:} What does the commit graph of your repository look
    like? Can you draw it on paper?
40
41
42

\bigskip

Vermaat's avatar
Vermaat committed
43
\emph{Hint:} Use \texttt{git log} with the appropriate arguments.
44
45
46

\bigskip

Vermaat's avatar
Vermaat committed
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}.
49
50
51

\bigskip

Vermaat's avatar
Vermaat committed
52
53
54
\subsubsection*{Fast-forward merging.}
Of course we want the nice commit your neighbour just made in our
\texttt{master} branch.
55
56
57

\bigskip

Vermaat's avatar
Vermaat committed
58
Merge the remote \texttt{master} branch into \texttt{master}.
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's avatar
Vermaat committed
68
The previous section produced a fast-forward merge.
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's avatar
Vermaat committed
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).
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's avatar
Vermaat committed
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.


94
\end{document}