From 03bb4e2fe1aec062fd3a87d0e9a7e2f337fb5f13 Mon Sep 17 00:00:00 2001 From: mlefter Date: Tue, 5 Sep 2017 13:14:28 +0200 Subject: [PATCH] Merging draft ready --- .../images/commit_graph/commit_graph_00.svg | 12 +- .../images/fast_forward/fast_forward_00.svg | 2224 ++++++++++++ merging/images/three_way/three_way_00.svg | 3114 +++++++++++++++++ merging/merging.tex | 511 +-- merging/merging_handouts.tex | 4 - 5 files changed, 5619 insertions(+), 246 deletions(-) create mode 100644 merging/images/fast_forward/fast_forward_00.svg create mode 100644 merging/images/three_way/three_way_00.svg diff --git a/merging/images/commit_graph/commit_graph_00.svg b/merging/images/commit_graph/commit_graph_00.svg index 71bee65..47b6985 100644 --- a/merging/images/commit_graph/commit_graph_00.svg +++ b/merging/images/commit_graph/commit_graph_00.svg @@ -10,8 +10,8 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="300.00003mm" - height="189.99992mm" - viewBox="0 0 1062.9922 673.22806" + height="190.00005mm" + viewBox="0 0 1062.9922 673.22852" id="svg2" version="1.1" inkscape:version="0.91 r13725" @@ -1916,7 +1916,7 @@ inkscape:pageshadow="2" inkscape:zoom="0.45932341" inkscape:cx="204.42657" - inkscape:cy="990.32019" + inkscape:cy="-446.35603" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -1933,11 +1933,11 @@ inkscape:guide-bbox="true" units="mm"> @@ -1957,7 +1957,7 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" - transform="translate(-63.5398,-9487.7809)"> + transform="translate(-63.5398,-8747.7809)"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + Git just moves 'master' (and HEAD) to point to 'hue/master'. + + + + Branch 'master' on 'hue'is one commit aheadof our 'master' branch. + + 00 + + + d1c7fd7 + + + + + + HEAD + + + Master + + + + c7f3bd9 + + + hue/master + + + Initial commit + + State character preference + + + hue/HEAD + + + + 01 + + + d1c7fd7 + + + + + + HEAD + + + Master + + + + c7f3bd9 + + + hue/master + + + Initial commit + + State character preference + + + hue/HEAD + + + + diff --git a/merging/images/three_way/three_way_00.svg b/merging/images/three_way/three_way_00.svg new file mode 100644 index 0000000..8adfdaa --- /dev/null +++ b/merging/images/three_way/three_way_00.svg @@ -0,0 +1,3114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + Branch 'master' on 'hue'and our 'master' have diverged.Merging now seems less straightforward. + + 00 + + + d1c7fd7 + + + + + + HEAD + + + Master + + + + c7f3bd9 + + + hue/master + + + Initial commit + + State character preference + + + hue/HEAD + + + + + + e313a21 + + + Add figures file + + 2de1234 + + + Change favorite character + + + + + + Git will create a new commit in whichit combines both changes.The merge commit has two parents. + + 01 + + + d1c7fd7 + + + + + c7f3bd9 + + + hue/master + + + Initial commit + + State character preference + + + hue/HEAD + + + + + + e313a21 + + + Add figures file + + 2de1234 + + + Change favorite character + + + + + HEAD + + + Master + + + + + + f11faa4 + + + Merge remote-trackingbranch 'hue/master' + + + + + 02 + + + d1c7fd7 + + + + + c7f3bd9 + + + hue/master + + + Initial commit + + State character preference + + + hue/HEAD + + + + + + e313a21 + + + Add figures file + + 2de1234 + + + Change favorite character + + + + + HEAD + + + Master + + + + + + f11faa4 + + + Merge remote-trackingbranch 'hue/master' + + + We send our local commits to the remote.They are merged into the remote branch.But only if this is a fast-forward merge.Diverging commits cannot be pushed directly. + + diff --git a/merging/merging.tex b/merging/merging.tex index 9c1c091..0735638 100644 --- a/merging/merging.tex +++ b/merging/merging.tex @@ -1,8 +1,10 @@ \documentclass[slidestop]{beamer} +\usepackage{framed} + \input{../shared/shared.tex} -\author{} +\author{Mihai Lefter} \title{\courseTitle} \providecommand{\mySubTitle}{Combining changes by merging} \providecommand{\myConference}{\courseTitle} @@ -10,6 +12,26 @@ \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} \lstset{ @@ -34,7 +56,7 @@ %\renewcommand{\pause}{} % Make the title page. -\makeTitleSlide{\includegraphics[width=3.5cm]{git_logo}} +\makeTitleSlide{\includegraphics[width=3.5cm]{../shared/git_logo.pdf}} \section{The Git commit graph} \subsection{A linear history} @@ -101,83 +123,83 @@ \section{Inspecting the commit graph} \subsection{An example repository} \begin{pframe} - \includegraphics[width=8cm]{example} - \smallskip - - \begin{itemize} - \item Branches \lstinline{license} and \lstinline{interface} diverged from - \lstinline{master}. - \item Only \lstinline{license} has been merged back into - \lstinline{master}. - \item Current branch is \lstinline{master}. - \end{itemize} + \begin{center} + \includegraphics[width=\textwidth]{images/inspect_commit_graph/inspect_commit_graph_00.pdf} + \end{center} \end{pframe} -\subsection{Showing the current branch: \lstinline{git status}} +\subsection{Showing the current branch} \begin{pframe} - \begin{lstlisting} -$ git status -# On branch master -nothing to commit (working directory clean) - \end{lstlisting} + \begin{framed} + \textcolor{cli-text}{\lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{status}}\\ + \lstinline{# On branch master}\\ + \lstinline{nothing to commit (working directory clean)}} + \end{framed} - Remember: you cannot type \lstinline{git status} enough! + Remember: you cannot type \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{status}} enough! \end{pframe} -\subsection{The commit log: \lstinline{git log}} +\subsection{The commit log} \begin{pframe} - \begin{lstlisting} -$ git log --oneline --decorate -c7f3bd9 (HEAD, master) Add .gitignore file -4a44c4e Merge branch 'license' -64af1ee Add course teachers to README -0fbe3e3 (license) Add MIT license -d1c7fd7 Initial commit with README - \end{lstlisting} - - \lstinline{--oneline}: Shows commit summary on one line. - - \lstinline{--decorate}: Adds branch information. + \begin{framed} + \textcolor{cli-text}{\lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{log}} + \textcolor{argument-color}{\lstinline{--oneline --decorate}}\\ + \textcolor{commit-id}{\lstinline{c7f3bd9}} \lstinline{(}\textcolor{head}{\lstinline{HEAD}} \lstinline{->} \textcolor{branch}{\lstinline{master}}\lstinline{) Add .gitignore file}\\ + \textcolor{commit-id}{\lstinline{4a44c4e}} \lstinline{Merge branch 'license'}\\ + \textcolor{commit-id}{\lstinline{64af1ee}} \lstinline{Add course teachers to README}\\ + \textcolor{commit-id}{\lstinline{0fbe3e3}} \lstinline{(}\textcolor{branch}{\lstinline{license}}\lstinline{) Add MIT license}\\ + \textcolor{commit-id}{\lstinline{d1c7fd7}} \lstinline{Initial commit with README} + } + \end{framed} + + \textcolor{argument-color}{\lstinline{--oneline}}: Shows commit summary on one line. + + \textcolor{argument-color}{\lstinline{--decorate}}: Adds branch information. \end{pframe} -\subsection{The commit log as a graph: \lstinline{git log}} +\subsection{The commit log as a graph} \begin{pframe} - \begin{lstlisting} -$ git log --oneline --decorate --graph --all -* 8fc25c1 (interface) Trivial Python interface -| * c7f3bd9 (HEAD, master) Add .gitignore file -|/ -* 4a44c4e Merge branch 'license' -|\ -| * 0fbe3e3 (license) Add MIT license -* | 64af1ee Add course teachers to README -|/ -* d1c7fd7 Initial commit with README - \end{lstlisting} - - \lstinline{--graph}: Shows the commit graph. - - \lstinline{--all}: Includes all branches instead of just the current. + \begin{framed} + \textcolor{cli-text}{\lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{log}} + \textcolor{argument-color}{\lstinline{--oneline --decorate --graph --all}}\\ + \lstinline{*} \textcolor{commit-id}{\lstinline{8fc25c1}} \lstinline{(}\textcolor{branch}{\lstinline{interface}}\lstinline{) Trivial Python interface}\\ + \lstinline{| *} \textcolor{commit-id}{\lstinline{c7f3bd9}} \lstinline{(}\textcolor{head}{\lstinline{HEAD}} \lstinline{->} \textcolor{branch}{\lstinline{master)}} \lstinline{Add .gitignore file}\\ + \lstinline{|/}\\ + \lstinline{*} \textcolor{commit-id}{\lstinline{4a44c4e}} \lstinline{Merge branch 'license'}\\ + \lstinline{|\\}\\ + \lstinline{| *} \textcolor{commit-id}{\lstinline{0fbe3e3}} \lstinline{(}\textcolor{branch}{\lstinline{license}}\lstinline{) Add MIT license}\\ + \lstinline{* |} \textcolor{commit-id}{\lstinline{64af1ee}} \lstinline{Add course teachers to README}\\ + \lstinline{|/}\\ + \lstinline{*} \textcolor{commit-id}{\lstinline{d1c7fd7}} \lstinline{Initial commit with README} + } + \end{framed} + \vspace{-0.2cm} + + \textcolor{argument-color}{\lstinline{--graph}}: Shows the commit graph. + + \textcolor{argument-color}{\lstinline{--all}}: Includes all branches instead of just the current one. \end{pframe} -\subsection{Annotated log as an alias} -\begin{pframe} - For convenience, we can create an alias for the \lstinline{git log} command - with all the arguments we just used: - \begin{lstlisting} -$ git config --global alias.l \ - 'log --oneline --decorate --graph --all' -$ git l -* 8fc25c1 (interface) Trivial Python interface -| * c7f3bd9 (HEAD, master) Add .gitignore file -|/ -* 4a44c4e Merge branch 'license' -... -\end{lstlisting} - - This alias is stored in the \lstinline{~/.gitconfig} file. You can also edit - that file manually. -\end{pframe} +% \subsection{Annotated log as an alias} +% \begin{pframe} +% For convenience, we can create an alias for the \lstinline{git log} command +% with all the arguments we just used: +% \begin{lstlisting} +% $ git config --global alias.l \ +% 'log --oneline --decorate --graph --all' +% $ git l +% * 8fc25c1 (interface) Trivial Python interface +% | * c7f3bd9 (HEAD, master) Add .gitignore file +% |/ +% * 4a44c4e Merge branch 'license' +% ... +% \end{lstlisting} +% +% This alias is stored in the \lstinline{~/.gitconfig} file. You can also edit +% that file manually. +% \end{pframe} + +\section{Merging from remotes} \subsection{Remote branches} \begin{pframe} @@ -189,82 +211,83 @@ $ git l \item Merging remote branches is just like merging local branches. \end{itemize} \bigskip - \includegraphics[width=10cm]{example-hue} \end{pframe} -\section{Merging from remotes} -\subsection{An example repository} +\subsection{Fast forward merging} \begin{pframe} - \includegraphics[width=10cm]{example-hue} - \smallskip - Branch \lstinline{master} on \lstinline{hue} is one commit ahead of our - \lstinline{master} and we have already seen how to merge - \lstinline{hue/master} into \lstinline{master}: - \begin{itemize} - \item \lstinline{git merge hue/master} - \item This was easy: Git just moves \lstinline{master} (and - \lstinline{HEAD}) to point to \lstinline{hue/master}. - \item It is called a {\em fast forward merge}. - \end{itemize} + \begin{framed} + \textcolor{cli-text}{\lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{fetch}} \textcolor{argument-color}{\lstinline{hue}} \vspace{-0.2cm}\\ + \tiny{ + \lstinline{remote: Counting objects: 5, done.} \vspace{-0.2cm}\\ + \lstinline{remote: Compressing objects: 100\% (2/2), done.} \vspace{-0.2cm}\\ + \lstinline{remote: Total 3 (delta 0), reused 0 (delta 0)} \vspace{-0.2cm}\\ + \lstinline{Unpacking objects: 100\% (3/3), done.} \vspace{-0.2cm}\\ + \lstinline{From 192.168.0.8:docs/tv-series} \vspace{-0.2cm}\\ + \lstinline{* [new branch] master -> hue/master}} + } + \end{framed} + \pause + \begin{center} + \includegraphics[width=0.8\textwidth]{images/fast_forward/fast_forward_00.pdf} + \end{center} \end{pframe} -\subsection{Fast forward merging: \lstinline{git merge}} \begin{pframe} - If a remote branch is ahead of us, it can be merged easily: - \begin{lstlisting} -$ git merge hue/master -Updating c7f3bd9..251a51b -Fast-forward -testlib.py | 2 + -1 file changed, 2 insertions(+) - \end{lstlisting} - - \includegraphics[width=10cm]{example-hue-merged} + If a remote branch is ahead of us, it can be merged easily: + \vspace{-0.4cm} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{merge}} \textcolor{argument-color}{\lstinline{hue/master}} \vspace{-0.2cm}\\ + \tiny{ + \lstinline{Updating c7f3bd9..251a51b} \vspace{-0.2cm}\\ + \lstinline{Fast-forward} \vspace{-0.2cm}\\ + \lstinline{testlib.py | 2 +} \vspace{-0.2cm}\\ + \lstinline{1 file changed, 2 insertions(+)} + } + } + \end{framed} + \pause + \begin{center} + \includegraphics[width=0.9\textwidth]{images/fast_forward/fast_forward_01.pdf} + \end{center} \end{pframe} -\subsection{An example repository} +\subsection{Three-way merging} \begin{pframe} - \includegraphics[width=8cm]{example-hue-diverged} - \smallskip + \begin{center} + \includegraphics[width=\textwidth]{images/three_way/three_way_00.pdf} + \end{center} +\end{pframe} - Branch \lstinline{master} on \lstinline{hue} and our \lstinline{master} have - diverged and merging now seems less straightforward. - \begin{itemize} - \item \lstinline{git merge hue/master} - \item Git will create a new commit in which it combines both changes. - \item It is called a {\em three-way merge}. - \item The {\em merge commit} has two parents. - \end{itemize} +\begin{pframe} + Let's merge the remote work on \lstinline{master} back into our local \lstinline{master}: + \vspace{-0.8cm} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{merge}} \textcolor{argument-color}{\lstinline{hue/master}} \vspace{-0.2cm}\\ + \tiny{ + \lstinline{Merge made by the 'recursive' strategy.} \vspace{-0.2cm}\\ + \lstinline{FACTS.md | 2 +-} \vspace{-0.2cm}\\ + \lstinline{1 file changed, 1 insertion(+), 1 deletion(-)} + } + } + \end{framed} \end{pframe} -\subsection{Three-way merging: \lstinline{git merge}} \begin{pframe} - Let's merge the remote work on \lstinline{master} back into our local - \lstinline{master}: - \begin{lstlisting} -$ git merge hue/master -Merge made by the 'recursive' strategy. - FACTS.md | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - \end{lstlisting} - - \includegraphics[width=9cm]{example-hue-merged2} + \begin{center} + \includegraphics[width=\textwidth]{images/three_way/three_way_01.pdf} + \end{center} \end{pframe} \subsection{The other way around} \begin{pframe} \lstinline{git push} also does an implicit \lstinline{git merge} on the remote. - \begin{itemize} - \item We send our local commits to the remote. - \item They are merged into the remote branch. - \item But only if this is a fast-forward merge. - \item Diverging commits {\em cannot be pushed directly}. - \end{itemize} - \bigskip - - \includegraphics[width=10cm]{example-hue-pushed} + \begin{center} + \includegraphics[width=0.9\textwidth]{images/three_way/three_way_02.pdf} + \end{center} \end{pframe} \section{Basic merge conflicts} @@ -289,156 +312,172 @@ Merge made by the 'recursive' strategy. \subsection{Setting the stage (1/3)} \begin{pframe} - \begin{lstlisting} -* 5edaf08 (hue/master, hue/HEAD) State character preference -| * f1ef19c (HEAD, master) State character preference -|/ -* 1f6d2ab Initial commit - \end{lstlisting} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{log}} + \textcolor{argument-color}{\lstinline{--oneline --decorate --graph --all}}\\ + \lstinline{* 5edaf08 (hue/master, hue/HEAD) State character ...}\\ + \lstinline{| * f1ef19c (HEAD, master) State character ...}\\ + \lstinline{|/}\\ + \lstinline{* 1f6d2ab Initial commit} + } + \end{framed} We'd like to merge branch \lstinline{hue/master} into \lstinline{master}. \end{pframe} \subsection{Setting the stage (2/3)} \begin{pframe} - The last commit on \lstinline{master}: - \begin{lstlisting} -f1ef19c State character preference -diff --git a/FACTS.md b/FACTS.md -index de15194..ef40359 100644 ---- a/FACTS.md -+++ b/FACTS.md -@@ -1,2 +1,4 @@ -Facts about television series -============================= -+ -+My favorite character is Eric Cartman. - \end{lstlisting} + The last commit on \lstinline{master}: + \vspace{-0.3cm} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{show}}\\ + \lstinline{f1ef19c State character preference}\\ + \lstinline{diff --git a/FACTS.md b/FACTS.md}\\ + \lstinline{index de15194..ef40359 100644}\\ + \lstinline{--- a/FACTS.md}\\ + \lstinline{+++ b/FACTS.md}\\ + \lstinline{@@ -1,2 +1,4 @@}\\ + \lstinline{Facts about television series}\\ + \lstinline{=============================}\\ + \lstinline{+}\\ + \lstinline{+My favorite character is Eric Cartman.} + } + \end{framed} \end{pframe} \subsection{Setting the stage (3/3)} \begin{pframe} - The last commit on \lstinline{hue/master}: - \begin{lstlisting} -$ git show --oneline hue/master -5edaf08 State character preference -diff --git a/FACTS.md b/FACTS.md -index de15194..5e69508 100644 ---- a/FACTS.md -+++ b/FACTS.md -@@ -1,2 +1,4 @@ -Facts about television series -============================= -+ -+My favorite character is Milhouse. - \end{lstlisting} + The last commit on \lstinline{hue/master}: + \vspace{-0.3cm} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{show}} + \textcolor{argument-color}{\lstinline{--oneline}} \textcolor{argument-color}{\lstinline{hue/master}}\\ + \lstinline{5edaf08 State character preference}\\ + \lstinline{diff --git a/FACTS.md b/FACTS.md}\\ + \lstinline{index de15194..5e69508 100644}\\ + \lstinline{--- a/FACTS.md}\\ + \lstinline{+++ b/FACTS.md}\\ + \lstinline{@@ -1,2 +1,4 @@}\\ + \lstinline{Facts about television series}\\ + \lstinline{=============================}\\ + \lstinline{+}\\ + \lstinline{+My favorite character is Milhouse.} + } + \end{framed} \end{pframe} \subsection{Creating a merge conflict} \begin{pframe} - \vspace{-0.5cm} - \begin{lstlisting} -$ git merge hue/master -Auto-merging FACTS.md -CONFLICT (content): Merge conflict in FACTS.md -Automatic merge failed; fix conflicts and then -commit the result. - -$ git status -# On branch master -# Unmerged paths: -# (use "git add/rm .." as appropriate to -# mark resolution) -# -# both modified: FACTS.md -# -no changes added to commit (use "git add" and/or -"git commit -a") - \end{lstlisting} + \vspace{-0.5cm} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{merge}} + \textcolor{argument-color}{\lstinline{hue/master}}\\ + \lstinline{Auto-merging FACTS.md}\\ + \lstinline{CONFLICT (content): Merge conflict in FACTS.md}\\ + \lstinline{Automatic merge failed; fix conflicts and then}\\ + \lstinline{commit the result.}\\ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{status}}\\ + \lstinline{# On branch master}\\ + \lstinline{# Unmerged paths:}\\ + \lstinline{# (use "git add/rm .." as appropriate)}\\ + \lstinline{# to mark resolution)}\\ + \lstinline{# both modified: FACTS.md}\\ + \lstinline{# no changes added to commit (use "git add" and/or}\\ + \lstinline{# "git commit -a")} + } + \end{framed} \end{pframe} -\subsection{Resolving a merge conflict (1/2)} +\subsection{Resolving a merge conflict (1/3)} \begin{pframe} - \begin{lstlisting} -$ cat FACTS.md -Facts about television series -============================= - -<<<<<<< HEAD -My favorite character is Eric Cartman. -======= -My favorite character is Milhouse. ->>>>>>> hue/master - \end{lstlisting} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{command-color}{\lstinline{cat}} \textcolor{argument-color}{\lstinline{FACTS.md}}\\ + \lstinline{Facts about television series}\\ + \lstinline{=============================}\\ + \textcolor{white}{\lstinline{S}}\\ + \lstinline{<<<<<<< HEAD}\\ + \lstinline{My favorite character is Eric Cartman.}\\ + \lstinline{=======}\\ + \lstinline{My favorite character is Milhouse.}\\ + \lstinline{>>>>>>> hue/master} + } + \end{framed} What we had is under \lstinline{HEAD}, what \lstinline{hue/master} had is above \lstinline{hue/master}. - \pause - - \begin{lstlisting} -$ nano FACTS.md - \end{lstlisting} \end{pframe} -\subsection{Resolving a merge conflict (2/2)} +\subsection{Resolving a merge conflict (2/3)} \begin{pframe} We resolve the conflict by hand. - \begin{lstlisting} -$ cat FACTS.md -Facts about television series -============================= - -My favorite characters are Eric Cartman -and Milhouse. - \end{lstlisting} - \pause + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{command-color}{\lstinline{nano}} \textcolor{argument-color}{\lstinline{FACTS.md}} \\ + \lstinline{$} \textcolor{command-color}{\lstinline{cat}} \textcolor{argument-color}{\lstinline{FACTS.md}} \\ + \lstinline{Facts about television series}\\ + \lstinline{=============================}\\ + \textcolor{white}{\lstinline{S}}\\ + \lstinline{My favorite characters are Eric Cartman}\\ + \lstinline{My favorite character is Eric Cartman.}\\ + \lstinline{and Milhouse.} + } + \end{framed} +\end{pframe} +\subsection{Resolving a merge conflict (3/3)} +\begin{pframe} And can now finish the merge commit. - \begin{lstlisting} -$ git add FACTS.md -$ git commit -[master 1e496cb] Merge remote-tracking branch -'hue/master' - \end{lstlisting} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{add}} \textcolor{argument-color}{\lstinline{FACTS.md}} \\ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{commit}} \\ + \lstinline{[master 1e496cb] Merge remote-tracking branch}\\ + \lstinline{'hue/master'} + } + \end{framed} \end{pframe} + \subsection{Aborting a merge} \begin{pframe} If you don't feel like resolving the merge conflict, you can go back with \lstinline{git merge --abort}. - \begin{lstlisting} -$ git merge hue/master -Auto-merging FACTS.md -CONFLICT (content): Merge conflict in FACTS.md -Automatic merge failed; fix conflicts and then -commit the result. - \end{lstlisting} - - \begin{lstlisting} -$ git merge --abort - \end{lstlisting} - - \begin{lstlisting} -$ git status -# On branch master -nothing to commit (working directory clean) - \end{lstlisting} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{merge}} \textcolor{argument-color}{\lstinline{hue/master}} \\ + \lstinline{Auto-merging FACTS.md}\\ + \lstinline{CONFLICT (content): Merge conflict in FACTS.md}\\ + \lstinline{Automatic merge failed; fix conflicts and then}\\ + \lstinline{commit the result.}\\ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{merge}} \textcolor{argument-color}{\lstinline{--abort}} \\ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{status}}\\ + \lstinline{# On branch master}\\ + \lstinline{# nothing to commit (working directory clean)} + } + \end{framed} \end{pframe} \subsection{Resolving conflicts with \lstinline{git mergetool}} \begin{pframe} We can also use graphical merge tools such as {\em Meld}. - \begin{lstlisting} -$ git mergetool -merge tool candidates: meld opendiff kdiff3 ... -Merging: -FACTS.md - -Normal merge conflict for 'FACTS.md': - {local}: modified file - {remote}: modified file -Hit return to start merge resolution tool (meld): - \end{lstlisting} + \begin{framed} + \textcolor{cli-text}{ + \lstinline{$} \textcolor{git-color}{\lstinline{git}} \textcolor{command-color}{\lstinline{mergetool}}\\ + \lstinline{merge tool candidates: meld opendiff kdiff3 ...}\\ + \lstinline{Merging:}\\ + \lstinline{FACTS.md}\\ + \textcolor{white}{\lstinline{S}}\\ + \lstinline{Normal merge conflict for 'FACTS.md':}\\ + \textcolor{white}{\lstinline{ss}}\lstinline{local: modified file}\\ + \textcolor{white}{\lstinline{ss}}\lstinline{remote: modified file}\\ + \lstinline{Hit return to start merge resolution tool (meld):} + } + \end{framed} \end{pframe} \subsection{Meld example} diff --git a/merging/merging_handouts.tex b/merging/merging_handouts.tex index 4a314d7..95a25ee 100644 --- a/merging/merging_handouts.tex +++ b/merging/merging_handouts.tex @@ -34,10 +34,6 @@ you draw it on paper? \emph{Hint:} Use \lstinline{git log} with the appropriate arguments. \bigskip -As an alternative to \lstinline{git log}, you can also try a graphical viewer -such as \lstinline{gitg} (installed on the course laptops) or \lstinline{gitk}. -\bigskip - \subsubsection*{Fast-forward merging} Of course we want the nice commit your neighbour just made in our \lstinline{master} branch. -- GitLab