OSDN Git Service

merge original branch.
[tortoisegit/TortoiseGitJp.git] / doc / source / en / TortoiseGit / git_doc / git-merge-base.html.xml
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-merge-base(1)">\r
5 <articleinfo>\r
6     <title>git-merge-base(1)</title>\r
7         <indexterm>\r
8                 <primary>git-merge-base(1)</primary>\r
9         </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-merge-base - Find as good common ancestors as possible for a merge</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <simpara><emphasis>git merge-base</emphasis> [--all] &lt;commit&gt; &lt;commit&gt;&#8230;</simpara>\r
18 </simplesect>\r
19 <simplesect id="_description">\r
20 <title>DESCRIPTION</title>\r
21 <simpara><emphasis>git-merge-base</emphasis> finds best common ancestor(s) between two commits to use\r
22 in a three-way merge.  One common ancestor is <emphasis>better</emphasis> than another common\r
23 ancestor if the latter is an ancestor of the former.  A common ancestor\r
24 that does not have any better common ancestor is a <emphasis>best common\r
25 ancestor</emphasis>, i.e. a <emphasis>merge base</emphasis>.  Note that there can be more than one\r
26 merge base for a pair of commits.</simpara>\r
27 <simpara>Among the two commits to compute the merge base from, one is specified by\r
28 the first commit argument on the command line; the other commit is a\r
29 (possibly hypothetical) commit that is a merge across all the remaining\r
30 commits on the command line.  As the most common special case, specifying only\r
31 two commits on the command line means computing the merge base between\r
32 the given two commits.</simpara>\r
33 </simplesect>\r
34 <simplesect id="_options">\r
35 <title>OPTIONS</title>\r
36 <variablelist>\r
37 <varlistentry>\r
38 <term>\r
39 --all\r
40 </term>\r
41 <listitem>\r
42 <simpara>\r
43         Output all merge bases for the commits, instead of just one.\r
44 </simpara>\r
45 </listitem>\r
46 </varlistentry>\r
47 </variablelist>\r
48 </simplesect>\r
49 <simplesect id="_discussion">\r
50 <title>DISCUSSION</title>\r
51 <simpara>Given two commits <emphasis>A</emphasis> and <emphasis>B</emphasis>, <literal>git merge-base A B</literal> will output a commit\r
52 which is reachable from both <emphasis>A</emphasis> and <emphasis>B</emphasis> through the parent relationship.</simpara>\r
53 <simpara>For example, with this topology:</simpara>\r
54 <literallayout class="monospaced">         o---o---o---B\r
55         /\r
56 ---o---1---o---o---o---A</literallayout>\r
57 <simpara>the merge base between <emphasis>A</emphasis> and <emphasis>B</emphasis> is <emphasis>1</emphasis>.</simpara>\r
58 <simpara>Given three commits <emphasis>A</emphasis>, <emphasis>B</emphasis> and <emphasis>C</emphasis>, <literal>git merge-base A B C</literal> will compute the\r
59 merge base between <emphasis>A</emphasis> and a hypothetical commit <emphasis>M</emphasis>, which is a merge\r
60 between <emphasis>B</emphasis> and <emphasis>C</emphasis>.  For example, with this topology:</simpara>\r
61 <literallayout class="monospaced">       o---o---o---o---C\r
62       /\r
63      /   o---o---o---B\r
64     /   /\r
65 ---2---1---o---o---o---A</literallayout>\r
66 <simpara>the result of <literal>git merge-base A B C</literal> is <emphasis>1</emphasis>.  This is because the\r
67 equivalent topology with a merge commit <emphasis>M</emphasis> between <emphasis>B</emphasis> and <emphasis>C</emphasis> is:</simpara>\r
68 <literallayout class="monospaced">       o---o---o---o---o\r
69       /                 \\r
70      /   o---o---o---o---M\r
71     /   /\r
72 ---2---1---o---o---o---A</literallayout>\r
73 <simpara>and the result of <literal>git merge-base A M</literal> is <emphasis>1</emphasis>.  Commit <emphasis>2</emphasis> is also a\r
74 common ancestor between <emphasis>A</emphasis> and <emphasis>M</emphasis>, but <emphasis>1</emphasis> is a better common ancestor,\r
75 because <emphasis>2</emphasis> is an ancestor of <emphasis>1</emphasis>.  Hence, <emphasis>2</emphasis> is not a merge base.</simpara>\r
76 <simpara>When the history involves criss-cross merges, there can be more than one\r
77 <emphasis>best</emphasis> common ancestor for two commits.  For example, with this topology:</simpara>\r
78 <literallayout class="monospaced">---1---o---A\r
79     \ /\r
80      X\r
81     / \\r
82 ---2---o---o---B</literallayout>\r
83 <simpara>both <emphasis>1</emphasis> and <emphasis>2</emphasis> are merge-bases of A and B.  Neither one is better than\r
84 the other (both are <emphasis>best</emphasis> merge bases).  When the <literal>--all</literal> option is not given,\r
85 it is unspecified which best one is output.</simpara>\r
86 </simplesect>\r
87 <simplesect id="_author">\r
88 <title>Author</title>\r
89 <simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;</simpara>\r
90 </simplesect>\r
91 <simplesect id="_documentation">\r
92 <title>Documentation</title>\r
93 <simpara>Documentation by David Greaves, Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>\r
94 </simplesect>\r
95 <simplesect id="_git">\r
96 <title>GIT</title>\r
97 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>\r
98 </simplesect>\r
99 </article>\r