<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE sect1 SYSTEM "../../../dtd/dblite.dtd">
<sect1 id="tgit-dug-rebase">
	<title>Rebase</title>
	<?dbhh topicname="HIDD_REBASE"?>
	<indexterm>
		<primary>Rebase</primary>
	</indexterm>
	<para>
		Rebase is quite complex and it alters/rewrites the history of a repository. Please make sure you understood its principles before using it (for general hints where to find more information about Git and rebasing see <xref linkend="tgit-preface-readingguide"/> and especially <gitdoclink cmd="git-rebase" section="1"/>).
	</para>
	<para>
		<menuchoice>
			<guimenu>TortoiseGit</guimenu>
			<guimenuitem>Rebase</guimenuitem>
		</menuchoice>
	</para>
	<para>
		The Rebase dialog will be shown.
		<figure id="tgit-dug-rebase-dia-rebasedialog">
			<title>Rebase dialog</title>
			<graphic fileref="../images/GitRebase.png"/>
		</figure>
	</para>
	<para>
		Rebasing commits takes places from the bottom of the list to the top (in ascending order of the ID column). For example, <option>squash</option> means that the commit gets squashed/combined with the previous commit(s) which are located below in the list (with a lower ID).
	</para>
	<tip>
		<para>
			Instead of setting <option>pick</option>, <option>skip</option>, <option>edit</option>, <option>squash</option> by using the context-menu, you can also use the following keys:
			<keycap>space</keycap>: shifts the state, <keycap>s</keycap>: <option>skip</option>, <keycap>e</keycap>: <option>edit</option>, <keycap>p</keycap>: <option>pick</option>, <keycap>q</keycap>: <option>squash</option>
		</para>
	</tip>
	<tip>
		<para>
			There is a button that swaps branch and upstream.
			Assume you are currently working on <literal>master</literal> branch,
			and wish to rebase <literal>feature</literal> branch onto <literal>master</literal>.
			Instead of switching to <literal>feature</literal> in advance,
			select the commit of <literal>feature</literal> in log list,
			<menuchoice>
				<guimenu>Context Menu</guimenu>
				<guimenuitem>Rebase</guimenuitem>
			</menuchoice>
			and click this swap button.
			TortoiseGit's rebase moves <literal>feature</literal> to <literal>master</literal> directly, then
			cherry-picks the commits. This approach touches fewer files and runs faster.
		</para>
	</tip>
	<important>
		<para>
			When preserving merge commits, re-ordering commits cannot be handled properly in all cases, see in known bugs of vanilla git rebase: <gitdoclink cmd="git-rebase" section="1"/>.
		</para>
	</important>
	<important>
		<title>Conflicts</title>
		<para>
			Although major merge work is done by git automatically while rebasing, a conflict may happen during rebase (i.e., a file was modified in both branches, the one you are rebasing one and the on which you are rebasing),
			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 of the branch you rebase onto and "LOCAL"/"mine" to your version on the branch which you are rebasing.
		</para>
	</important>
</sect1>
