Skip to content

Commit c33e8c8

Browse files
committed
add merge conflict section
1 parent b29fcad commit c33e8c8

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

source/ch-collaboration.ptx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,66 @@ and open a pull request.
273273
<section xml:id="sec-conflicts">
274274
<title>Handling Merge Conflicts</title>
275275
<p>
276-
To come in a future revision of this handbook...
276+
Perhaps the most complicated scenario when collaborating
277+
on a Git repository is the dreaded <em>merge conflict</em>.
278+
</p>
279+
<definition xml:id="def-merge-conflict">
280+
<statement>
281+
<p>
282+
While Git is fairly good about merging together changes
283+
made by different contributors to different
284+
files within a project into a cohesive whole, a
285+
<term>merge conflict</term> can occur when two different
286+
contributors attempt to make changes to the same file
287+
(particularly, the same line) at the same time. When the
288+
second contributor opens a pull request, GitHub will warn
289+
about this conflict.
290+
</p>
291+
</statement>
292+
</definition>
293+
<p>
294+
Handling merge conflicts can be tricky!
295+
Git/GitHub have various tools to help you review and correct
296+
a merge conflict. If you're fortunate, you'll be able to resolve
297+
things on the pull request page: see
298+
<url href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github">
299+
Resolving a merge conflict on GitHub
300+
</url> for full details.
301+
</p>
302+
<p>
303+
You'll be presented with files with some strange markers as in
304+
<xref ref="listing-merge-conflict"/>. The lines between
305+
<c>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</c> and
306+
<c>=======</c> were merged first, and the lines between
307+
<c>=======</c> and
308+
<c>&gt;&gt;&gt;&gt;&gt;&gt;&gt; branch-a</c> are the conflicting
309+
changes trying to be merged.
310+
</p>
311+
<listing xml:id="listing-merge-conflict">
312+
<program>
313+
<input>If you have questions, please
314+
&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
315+
open an Issue
316+
=======
317+
ask them in Discussions.
318+
&gt;&gt;&gt;&gt;&gt;&gt;&gt; branch-a
319+
</input>
320+
</program>
321+
<caption>A merge conflict</caption>
322+
</listing>
323+
<p>
324+
You can then choose which change to retain, deleting all the
325+
extra <c>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</c>,
326+
<c>=======</c>, and
327+
<c>&gt;&gt;&gt;&gt;&gt;&gt;&gt; branch-a</c> lines.
328+
</p>
329+
<p>
330+
However, sometimes the merge conflict is too involved to be
331+
corrected using the web interface. In that situation, you will
332+
need to use a Codespace and follow the instructions at either
333+
<url href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line">Resolving a merge conflict using the command line</url>
334+
or
335+
<url href="https://code.visualstudio.com/docs/sourcecontrol/overview#_merge-conflicts">Using Git source control in VS Code | Merge conflicts</url>.
277336
</p>
278337
</section>
279338
</chapter>

0 commit comments

Comments
 (0)