Skip to content
Snippets Groups Projects
Commit ec5afcc0 authored by Laurent Modolo's avatar Laurent Modolo
Browse files

section on merge with conflict

parent a914fc6f
Branches
No related tags found
No related merge requests found
img/19-b4-master-deputy-on-b4.png

13.3 KiB

img/20-b5-on-deputy-b6-on-master.png

14.4 KiB

img/22-b11-on-master.png

14.5 KiB

......@@ -201,7 +201,7 @@ git create a new \textbf{blob} file in the \mintinline{sh}{.git/objects/} direct
\begin{shcode}
├── objects
│ ├── 78
│ │ └── 981922613b2afb6025042ff6bd878ac1994e85
│ │ └── 981922613b2afb602...
\end{shcode}
\vspace{-2.5em}
......@@ -226,7 +226,7 @@ alpha
├── index
├── objects
│ ├── 78
│ │ └── 981922613b2afb6025042ff6bd878ac1994e85
│ │ └── 981922613b2afb602...
etc...
\end{shcode}
\vspace{-2.5em}
......@@ -259,9 +259,9 @@ Git create a new blob\\[-2.5em]
└── .git
├── objects
│ ├── 27
│ │ └── 4c0052dd5408f8ae2bc8440029ff67d79bc5c3
│ │ └── 4c0052dd5408f8ae2...
│ ├── 78
│ │ └── 981922613b2afb6025042ff6bd878ac1994e85
│ │ └── 981922613b2afb602...
\end{shcode}
\vspace{-2.5em}
......@@ -288,11 +288,11 @@ git creates a new blob for the new \mintinline{sh}{data/number.txt}\\[-2.5em]
\begin{shcode}
├── objects
│ ├── 27
│ │ └── 4c0052dd5408f8ae2bc8440029ff67d79bc5c3
│ │ └── 4c0052dd5408f8ae2...
│ ├── 56
│ │ └── a6051ca2b02b04ef92d5150c9ef600403cb1de
│ │ └── a6051ca2b02b04ef9...
│ ├── 78
│ │ └── 981922613b2afb6025042ff6bd878ac1994e85
│ │ └── 981922613b2afb602...
\end{shcode}
\vspace{-2.5em}
......@@ -905,4 +905,177 @@ The entry for \mintinline{sh}{data/letter.txt} is pointed at the \textbf{b} blob
}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Git merge: with conflicts}
\vspace{-0.5em}
\begin{shcode}
~/alpha $ git checkout master
Switched to branch 'master'
~/alpha $ git merge deputy
Updating 0a888ed..38a9a35
Fast-forward
data/letter.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
\end{shcode}
\vspace{-2.5em}
\begin{center}
\includegraphics[width=0.9\textwidth]{./img/19-b4-master-deputy-on-b4.png}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Git merge: with conflicts}
We create a conflict between \mintinline{sh}{master} and \mintinline{sh}{deputy}\\[-2em]
\begin{shcode}
~/alpha $ git checkout deputy
Switched to branch 'deputy'
~/alpha $ printf '5' > data/number.txt
~/alpha $ git add data/number.txt
~/alpha $ git commit -m 'b5'
[deputy 34d4355] b5
1 file changed, 1 insertion(+), 1 deletion(-)
\end{shcode}
\vspace{-2.5em}
\vspace{-0.5em}
\begin{shcode}
~/alpha $ git checkout master
Switched to branch 'master'
~/alpha $ printf '6' > data/number.txt
~/alpha $ git add data/number.txt
~/alpha $ git commit -m 'b6'
[master b52c5a6] b6
1 file changed, 1 insertion(+), 1 deletion(-)
\end{shcode}
\vspace{-2.5em}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Git merge: with conflicts}
\vspace{-0.5em}
\begin{shcode}
~/alpha $ git merge deputy
Auto-merging data/number.txt
CONFLICT (content): Merge conflict in data/number.txt
Automatic merge failed; fix conflicts and then
commit the result.
\end{shcode}
\vspace{-2.5em}
There is a conflict and the merge is paused\\
We go through the same 8 steps as before but pause at step 6
\begin{center}
\includegraphics[width=0.9\textwidth]{./img/20-b5-on-deputy-b6-on-master.png}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Git merge: with conflicts}
\vspace{-0.5em}
\begin{shcode}
~/alpha $ git merge deputy
Auto-merging data/number.txt
CONFLICT (content): Merge conflict in data/number.txt
Automatic merge failed; fix conflicts and then
commit the result.
\end{shcode}
\vspace{-2.5em}
\begin{enumerate}
\setcounter{enumi}{3}
\item generates a diff that combines the changes made to the base by the receiver commit and the giver commit
\end{enumerate}
The entry is marked as a conflict because the content for \mintinline{sh}{data/number.txt} is different in the \textbf{receiver}, \textbf{giver} and \textbf{base}.
\vspace{5.8em}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Git merge: with conflicts}
\vspace{-0.5em}
\begin{shcode}
~/alpha $ git merge deputy
Auto-merging data/number.txt
CONFLICT (content): Merge conflict in data/number.txt
Automatic merge failed; fix conflicts and then
commit the result.
\end{shcode}
\vspace{-2.5em}
\begin{enumerate}
\setcounter{enumi}{4}
\item changes indicated by the entries in the diff are applied to the working copy
\end{enumerate}
Git writes both versions to the file in the working copy. The content of \mintinline{sh}{data/number.txt}
\begin{shcode}
<<<<<<< HEAD
6
=======
5
>>>>>>> deputy
\end{shcode}
\vspace{-2.6em}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Git merge: with conflicts}
\vspace{-0.5em}
\begin{shcode}
~/alpha $ git merge deputy
Auto-merging data/number.txt
CONFLICT (content): Merge conflict in data/number.txt
Automatic merge failed; fix conflicts and then
commit the result.
\end{shcode}
\vspace{-2.5em}
\begin{enumerate}
\setcounter{enumi}{5}
\item changes indicated by the entries in the diff are applied to the index
\end{enumerate}
{\small
The entry for an unconflicted file has a stage of \textbf{0}. For conflicted file we have \textbf{1} for the \textbf{base}, \textbf{2} for the \textbf{receiver} and \textbf{3} for the \textbf{giver}. These three entries tells Git that \mintinline{sh}{data/number.txt} is in conflict.}\\[-2em]
\begin{shcode}
0 data/letter.txt 63d8dbd40c23542e740...
1 data/number.txt bf0d87ab1b2b0ec1a11...
2 data/number.txt 62f9457511f879886bb...
3 data/number.txt 7813681f5b41c028345...
\end{shcode}
\vspace{-2.4em}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Git merge: with conflicts}
We resolve the confict\\[-2.5em]
\begin{shcode}
~/alpha $ printf '11' > data/number.txt
~/alpha $ git add data/number.txt
\end{shcode}
\vspace{-2.5em}
We complet the merge\\[-2.5em]
\begin{shcode}
~/alpha $ git commit -m 'b11'
[master bbd1f9b] b11
\end{shcode}
\vspace{-2.5em}
\begin{center}
\includegraphics[width=0.9\textwidth]{./img/22-b11-on-master.png}
\end{center}
\end{frame}
\end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment