<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 SYSTEM "../../../dtd/dblite.dtd">
<sect1 id="tgit-dug-merge" xmlns:xi="http://www.w3.org/2001/XInclude">
	<title>Merging</title>
	<?dbhh topicname="HIDD_MERGE"?>
	<indexterm>
		<primary>merge</primary>
	</indexterm>
	<para>
		Where branches are used to maintain separate lines of development,
		at some stage you will want to merge the changes made on one branch
		back into the other branch, or vice versa.
	</para>
	<para>
		It is important to understand how branching and merging works in
		Git before you start using it, as it can become quite complex.
		For hints where to find more information about Git and merging see <xref linkend="tgit-preface-readingguide"/>.
	</para>
	<para>
		The next point to note is that merging <emphasis>always</emphasis>
		takes place within a working tree. If you want to merge changes
		<emphasis>into</emphasis> a branch, you have to have a working tree
		for that branch checked out, and invoke the merge wizard from that
		working tree using
		<menuchoice>
			<guimenu>TortoiseGit</guimenu>
			<guimenuitem>Merge...</guimenuitem>
		</menuchoice>.
		<figure id="tgit-dug-merge-dia-1">
			<title>Merge dialog</title>
			<graphic fileref="../images/Merge.png"/>
		</figure>
	</para>
	<para>
		In general it is a good idea to perform a merge into an unmodified
		working tree. If you have made other changes in your working tree, commit those
		first. If the merge does not go as you expect, you may want to abort the merge using the <guilabel>Abort Merge</guilabel> command which might discard
		<emphasis>all</emphasis> changes (depending on the mode, in case of <guilabel>hard</guilabel>).
	</para>
	<para>
		You can choose one commit that you want to merge from.
		<xi:include href="./dug_chooseversion.xml"/>
	</para>
	<para>
		<guilabel>Squash</guilabel> Just merge change from the other branch. Can't
		recorder Merge information. The new commit will not record merge branch as
		one parent commit. Log view will not show merge line between two branch.
	</para>
	<para>
		<guilabel>No Fast Forward</guilabel> Generate a merge commit even if the
		merge resolved as a fast-forward. See <ulink url="https://stackoverflow.com/q/41794529/3906760">https://stackoverflow.com/q/41794529/3906760</ulink> for an example of fast-forward vs. non-fast-forward merge.
	</para>
	<para>
		<guilabel>No Commit</guilabel> Do not automatically create a commit after merge.
	</para>
	<para>
		<guilabel>Messages</guilabel> Populate the log message with one-line descriptions
		from the actual commits that are being merged. Can specify the number of commits
		to be included in the merge message.
	</para>
	<important>
		<title>Conflicts</title>
		<para>
			Although major merge work is done by git automatically, a conflict may happen during merge (i.e., a file is modified in both branches, the current one and the one you want to merge),
			please see <xref linkend="tgit-dug-conflicts"/> on how to resolve conflicts.
		</para>
		<para>
			Please note, that "REMOTE"/"theirs" in the conflict editor refers to the changes your on the branch you selected for merging and "LOCAL"/"mine" to your HEAD version in your working tree.
		</para>
	</important>
	<para>
		You can see more information at <gitdoclink cmd="git-merge" section="1"/>.
	</para>
</sect1>
