Commit 5cc09f6f authored by Martijn Vermaat's avatar Martijn Vermaat

Complete slides on branching

parent 818df604
......@@ -371,7 +371,170 @@ Deleted branch license (was 0fbe3e3).
\end{frame}
% todo: basic merge conflicts, tags
\section{Basic merge conflicts}
\begin{frame}
\frametitle{Merge conflicts}
Git is pretty good at merging:
\begin{itemize}
\item The changes might have been in different files.
\item Or in different parts of the same file.
\item Git tries to figure out a sensible result.
\end{itemize}
\pause
\bigskip
Sometimes this is not possible:
\begin{itemize}
\item The changes might be incompatible.
\item When we try \bt{git merge}, Git gives up.
\item This situation is called a {\em merge conflict}.
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Setting the stage (1/3)}
\begin{lstlisting}
$ git log --oneline --decorate --graph --all
* 9d2ad27 (HEAD, master) State character preference
| * 374ab60 (simpsons) State character preference
|/
* 4012f4f Initial commit
\end{lstlisting}
\bigskip
We'd like to merge branch \bt{simpsons} into \bt{master}.
\end{frame}
\begin{frame}[fragile]
\frametitle{Setting the stage (2/3)}
The last commit on \bt{master}:
\bigskip
\begin{lstlisting}
$ git show --oneline
9d2ad27 State character preference
diff --git a/README b/README
index de15194..ef40359 100644
--- a/README
+++ b/README
@@ -1,2 +1,4 @@
Facts about television series
=============================
+
+My favorite character is Eric Cartman.
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Setting the stage (3/3)}
The last commit on \bt{simpsons}:
\bigskip
\begin{lstlisting}
$ git show --oneline simpsons
374ab60 State character preference
diff --git a/README b/README
index de15194..9dd729b 100644
--- a/README
+++ b/README
@@ -1,2 +1,4 @@
Facts about television series
=============================
+
+My favorite character is Homer Simpson.
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Creating a merge conflict}
\begin{lstlisting}
$ git merge simpsons
Auto-merging README
CONFLICT (content): Merge conflict in README
Automatic merge failed; fix conflicts and then
commit the result.
\end{lstlisting}
\bigskip
\begin{lstlisting}
$ git status
# On branch master
# Unmerged paths:
# (use "git add/rm <file>.." as appropriate to
# mark resolution)
#
# both modified: README
#
no changes added to commit (use "git add" and/or
"git commit -a")
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Resolving a merge conflict (1/2)}
\begin{lstlisting}
$ cat README
Facts about television series
=============================
<<<<<<< HEAD
My favorite character is Eric Cartman.
=======
My favorite character is Homer Simpson.
>>>>>>> simpsons
\end{lstlisting}
\bigskip
What we had is under \bt{HEAD}, what \bt{simpsons} had is above
\bt{simpsons}.
\pause
\bigskip
\begin{lstlisting}
$ emacs README
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Resolving a merge conflict (1/2)}
We resolve the conflict by hand.
\bigskip
\begin{lstlisting}
$ cat README
Facts about television series
=============================
My favorite characters are Eric Cartman
and Homer Simpson.
\end{lstlisting}
\pause
\bigskip
And can now finish the merge commit.
\bigskip
\begin{lstlisting}
$ git add README
$ git commit
[master 1e496cb] Merge branch 'simpsons'
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Resolving conflicts with \bt{git mergetool}}
We can also use graphical merge tools such as {\em Meld}.
\bigskip
\begin{lstlisting}
$ git mergetool
merge tool candidates: meld opendiff kdiff3 ...
Merging:
README
Normal merge conflict for 'README':
{local}: modified file
{remote}: modified file
Hit return to start merge resolution tool (meld):
\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{Meld example}
\includegraphics[width=11cm]{images/meld}\\
\vspace{0.5cm}
Tools like Meld provide an editable three-way diff.
\end{frame}
\section{Questions?}
......
This diff is collapsed.
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