summaryrefslogtreecommitdiffstats
path: root/gitcore-tutorial.html
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-12-18 16:43:11 -0800
committerJunio C Hamano <gitster@pobox.com>2012-12-18 16:43:11 -0800
commit9d9711544dc3090db6e5c52f9ce9c300bf4f5c14 (patch)
tree23257b9801739fd96c9e82ef98a17500dce9f88e /gitcore-tutorial.html
parent9629d4f49e5ffcff5c5beb5c40bedcffcabcd905 (diff)
downloadgit-htmldocs-9d9711544dc3090db6e5c52f9ce9c300bf4f5c14.tar.gz
Autogenerated HTML docs for v1.8.1-rc2-5-g252f9
Diffstat (limited to 'gitcore-tutorial.html')
-rw-r--r--gitcore-tutorial.html1016
1 files changed, 609 insertions, 407 deletions
diff --git a/gitcore-tutorial.html b/gitcore-tutorial.html
index 281b36379..0e91956ae 100644
--- a/gitcore-tutorial.html
+++ b/gitcore-tutorial.html
@@ -2,15 +2,25 @@
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<meta name="generator" content="AsciiDoc 8.5.2" />
+<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
+<meta name="generator" content="AsciiDoc 8.6.8" />
<title>gitcore-tutorial(7)</title>
<style type="text/css">
-/* Debug borders */
-p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
-/*
- border: 1px solid red;
-*/
+/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
+
+/* Default font. */
+body {
+ font-family: Georgia,serif;
+}
+
+/* Title font. */
+h1, h2, h3, h4, h5, h6,
+div.title, caption.title,
+thead, p.table.header,
+#toctitle,
+#author, #revnumber, #revdate, #revremark,
+#footer {
+ font-family: Arial,Helvetica,sans-serif;
}
body {
@@ -35,13 +45,8 @@ strong {
color: #083194;
}
-tt {
- color: navy;
-}
-
h1, h2, h3, h4, h5, h6 {
color: #527bbd;
- font-family: sans-serif;
margin-top: 1.2em;
margin-bottom: 0.5em;
line-height: 1.3;
@@ -59,9 +64,11 @@ h3 {
h3 + * {
clear: left;
}
+h5 {
+ font-size: 1.0em;
+}
div.sectionbody {
- font-family: serif;
margin-left: 0;
}
@@ -77,45 +84,48 @@ p {
ul, ol, li > p {
margin-top: 0;
}
+ul > li { color: #aaa; }
+ul > li > * { color: black; }
-pre {
+.monospaced, code, pre {
+ font-family: "Courier New", Courier, monospace;
+ font-size: inherit;
+ color: navy;
padding: 0;
margin: 0;
}
-span#author {
+
+#author {
color: #527bbd;
- font-family: sans-serif;
font-weight: bold;
font-size: 1.1em;
}
-span#email {
+#email {
}
-span#revnumber, span#revdate, span#revremark {
- font-family: sans-serif;
+#revnumber, #revdate, #revremark {
}
-div#footer {
- font-family: sans-serif;
+#footer {
font-size: small;
border-top: 2px solid silver;
padding-top: 0.5em;
margin-top: 4.0em;
}
-div#footer-text {
+#footer-text {
float: left;
padding-bottom: 0.5em;
}
-div#footer-badges {
+#footer-badges {
float: right;
padding-bottom: 0.5em;
}
-div#preamble {
+#preamble {
margin-top: 1.5em;
margin-bottom: 1.5em;
}
-div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
+div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
margin-top: 1.0em;
@@ -135,7 +145,6 @@ div.content { /* Block element content. */
/* Block element titles. */
div.title, caption.title {
color: #527bbd;
- font-family: sans-serif;
font-weight: bold;
text-align: left;
margin-top: 1.0em;
@@ -157,13 +166,15 @@ div.content + div.title {
div.sidebarblock > div.content {
background: #ffffee;
- border: 1px solid silver;
+ border: 1px solid #dddddd;
+ border-left: 4px solid #f0f0f0;
padding: 0.5em;
}
div.listingblock > div.content {
- border: 1px solid silver;
- background: #f4f4f4;
+ border: 1px solid #dddddd;
+ border-left: 5px solid #f0f0f0;
+ background: #f8f8f8;
padding: 0.5em;
}
@@ -171,8 +182,8 @@ div.quoteblock, div.verseblock {
padding-left: 1.0em;
margin-left: 1.0em;
margin-right: 10%;
- border-left: 5px solid #dddddd;
- color: #777777;
+ border-left: 5px solid #f0f0f0;
+ color: #888;
}
div.quoteblock > div.attribution {
@@ -180,8 +191,9 @@ div.quoteblock > div.attribution {
text-align: right;
}
-div.verseblock > div.content {
- white-space: pre;
+div.verseblock > pre.content {
+ font-family: inherit;
+ font-size: inherit;
}
div.verseblock > div.attribution {
padding-top: 0.75em;
@@ -254,35 +266,12 @@ div.compact div, div.compact div {
margin-bottom: 0.1em;
}
-div.tableblock > table {
- border: 3px solid #527bbd;
-}
-thead, p.table.header {
- font-family: sans-serif;
- font-weight: bold;
-}
tfoot {
font-weight: bold;
}
td > div.verse {
white-space: pre;
}
-p.table {
- margin-top: 0;
-}
-/* Because the table frame attribute is overriden by CSS in most browsers. */
-div.tableblock > table[frame="void"] {
- border-style: none;
-}
-div.tableblock > table[frame="hsides"] {
- border-left-style: none;
- border-right-style: none;
-}
-div.tableblock > table[frame="vsides"] {
- border-top-style: none;
- border-bottom-style: none;
-}
-
div.hdlist {
margin-top: 0.8em;
@@ -339,25 +328,32 @@ span.footnote, span.footnoteref {
min-width: 100px;
}
+div.colist td {
+ padding-right: 0.5em;
+ padding-bottom: 0.3em;
+ vertical-align: top;
+}
+div.colist td img {
+ margin-top: 0.3em;
+}
@media print {
- div#footer-badges { display: none; }
+ #footer-badges { display: none; }
}
-div#toc {
+#toc {
margin-bottom: 2.5em;
}
-div#toctitle {
+#toctitle {
color: #527bbd;
- font-family: sans-serif;
font-size: 1.1em;
font-weight: bold;
margin-top: 1.0em;
margin-bottom: 0.1em;
}
-div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
+div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
margin-top: 0;
margin-bottom: 0;
}
@@ -373,69 +369,173 @@ div.toclevel4 {
margin-left: 6em;
font-size: 0.9em;
}
-/* Overrides for manpage documents */
-h1 {
- padding-top: 0.5em;
- padding-bottom: 0.5em;
- border-top: 2px solid silver;
- border-bottom: 2px solid silver;
+
+span.aqua { color: aqua; }
+span.black { color: black; }
+span.blue { color: blue; }
+span.fuchsia { color: fuchsia; }
+span.gray { color: gray; }
+span.green { color: green; }
+span.lime { color: lime; }
+span.maroon { color: maroon; }
+span.navy { color: navy; }
+span.olive { color: olive; }
+span.purple { color: purple; }
+span.red { color: red; }
+span.silver { color: silver; }
+span.teal { color: teal; }
+span.white { color: white; }
+span.yellow { color: yellow; }
+
+span.aqua-background { background: aqua; }
+span.black-background { background: black; }
+span.blue-background { background: blue; }
+span.fuchsia-background { background: fuchsia; }
+span.gray-background { background: gray; }
+span.green-background { background: green; }
+span.lime-background { background: lime; }
+span.maroon-background { background: maroon; }
+span.navy-background { background: navy; }
+span.olive-background { background: olive; }
+span.purple-background { background: purple; }
+span.red-background { background: red; }
+span.silver-background { background: silver; }
+span.teal-background { background: teal; }
+span.white-background { background: white; }
+span.yellow-background { background: yellow; }
+
+span.big { font-size: 2em; }
+span.small { font-size: 0.6em; }
+
+span.underline { text-decoration: underline; }
+span.overline { text-decoration: overline; }
+span.line-through { text-decoration: line-through; }
+
+div.unbreakable { page-break-inside: avoid; }
+
+
+/*
+ * xhtml11 specific
+ *
+ * */
+
+div.tableblock {
+ margin-top: 1.0em;
+ margin-bottom: 1.5em;
}
-h2 {
+div.tableblock > table {
+ border: 3px solid #527bbd;
+}
+thead, p.table.header {
+ font-weight: bold;
+ color: #527bbd;
+}
+p.table {
+ margin-top: 0;
+}
+/* Because the table frame attribute is overriden by CSS in most browsers. */
+div.tableblock > table[frame="void"] {
border-style: none;
}
-div.sectionbody {
- margin-left: 5%;
+div.tableblock > table[frame="hsides"] {
+ border-left-style: none;
+ border-right-style: none;
}
-
-@media print {
- div#toc { display: none; }
+div.tableblock > table[frame="vsides"] {
+ border-top-style: none;
+ border-bottom-style: none;
}
-/* Workarounds for IE6's broken and incomplete CSS2. */
-div.sidebar-content {
- background: #ffffee;
- border: 1px solid silver;
- padding: 0.5em;
+/*
+ * html5 specific
+ *
+ * */
+
+table.tableblock {
+ margin-top: 1.0em;
+ margin-bottom: 1.5em;
}
-div.sidebar-title, div.image-title {
- color: #527bbd;
- font-family: sans-serif;
+thead, p.tableblock.header {
font-weight: bold;
- margin-top: 0.0em;
- margin-bottom: 0.5em;
+ color: #527bbd;
+}
+p.tableblock {
+ margin-top: 0;
+}
+table.tableblock {
+ border-width: 3px;
+ border-spacing: 0px;
+ border-style: solid;
+ border-color: #527bbd;
+ border-collapse: collapse;
+}
+th.tableblock, td.tableblock {
+ border-width: 1px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #527bbd;
}
-div.listingblock div.content {
- border: 1px solid silver;
- background: #f4f4f4;
- padding: 0.5em;
+table.tableblock.frame-topbot {
+ border-left-style: hidden;
+ border-right-style: hidden;
+}
+table.tableblock.frame-sides {
+ border-top-style: hidden;
+ border-bottom-style: hidden;
+}
+table.tableblock.frame-none {
+ border-style: hidden;
}
-div.quoteblock-attribution {
- padding-top: 0.5em;
+th.tableblock.halign-left, td.tableblock.halign-left {
+ text-align: left;
+}
+th.tableblock.halign-center, td.tableblock.halign-center {
+ text-align: center;
+}
+th.tableblock.halign-right, td.tableblock.halign-right {
text-align: right;
}
-div.verseblock-content {
- white-space: pre;
+th.tableblock.valign-top, td.tableblock.valign-top {
+ vertical-align: top;
}
-div.verseblock-attribution {
- padding-top: 0.75em;
- text-align: left;
+th.tableblock.valign-middle, td.tableblock.valign-middle {
+ vertical-align: middle;
+}
+th.tableblock.valign-bottom, td.tableblock.valign-bottom {
+ vertical-align: bottom;
}
-div.exampleblock-content {
- border-left: 3px solid #dddddd;
- padding-left: 0.5em;
+
+/*
+ * manpage specific
+ *
+ * */
+
+body.manpage h1 {
+ padding-top: 0.5em;
+ padding-bottom: 0.5em;
+ border-top: 2px solid silver;
+ border-bottom: 2px solid silver;
+}
+body.manpage h2 {
+ border-style: none;
+}
+body.manpage div.sectionbody {
+ margin-left: 3em;
+}
+
+@media print {
+ body.manpage div#toc { display: none; }
}
-/* IE6 sets dynamically generated links as visited. */
-div#toc a:visited { color: blue; }
+
</style>
<script type="text/javascript">
/*<![CDATA[*/
-window.onload = function(){asciidoc.footnotes();}
var asciidoc = { // Namespace.
/////////////////////////////////////////////////////////////////////
@@ -477,7 +577,7 @@ toc: function (toclevels) {
function tocEntries(el, toclevels) {
var result = new Array;
- var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
+ var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
// Function that scans the DOM tree for header elements (the DOM2
// nodeIterator API would be a better technique but not supported by all
// browsers).
@@ -497,6 +597,25 @@ toc: function (toclevels) {
}
var toc = document.getElementById("toc");
+ if (!toc) {
+ return;
+ }
+
+ // Delete existing TOC entries in case we're reloading the TOC.
+ var tocEntriesToRemove = [];
+ var i;
+ for (i = 0; i < toc.childNodes.length; i++) {
+ var entry = toc.childNodes[i];
+ if (entry.nodeName.toLowerCase() == 'div'
+ && entry.getAttribute("class")
+ && entry.getAttribute("class").match(/^toclevel/))
+ tocEntriesToRemove.push(entry);
+ }
+ for (i = 0; i < tocEntriesToRemove.length; i++) {
+ toc.removeChild(tocEntriesToRemove[i]);
+ }
+
+ // Rebuild TOC entries.
var entries = tocEntries(document.getElementById("content"), toclevels);
for (var i = 0; i < entries.length; ++i) {
var entry = entries[i];
@@ -524,24 +643,44 @@ toc: function (toclevels) {
*/
footnotes: function () {
- var cont = document.getElementById("content");
+ // Delete existing footnote entries in case we're reloading the footnodes.
+ var i;
var noteholder = document.getElementById("footnotes");
+ if (!noteholder) {
+ return;
+ }
+ var entriesToRemove = [];
+ for (i = 0; i < noteholder.childNodes.length; i++) {
+ var entry = noteholder.childNodes[i];
+ if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
+ entriesToRemove.push(entry);
+ }
+ for (i = 0; i < entriesToRemove.length; i++) {
+ noteholder.removeChild(entriesToRemove[i]);
+ }
+
+ // Rebuild footnote entries.
+ var cont = document.getElementById("content");
var spans = cont.getElementsByTagName("span");
var refs = {};
var n = 0;
for (i=0; i<spans.length; i++) {
if (spans[i].className == "footnote") {
n++;
- // Use [\s\S] in place of . so multi-line matches work.
- // Because JavaScript has no s (dotall) regex flag.
- note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
+ var note = spans[i].getAttribute("data-note");
+ if (!note) {
+ // Use [\s\S] in place of . so multi-line matches work.
+ // Because JavaScript has no s (dotall) regex flag.
+ note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
+ spans[i].innerHTML =
+ "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
+ "' title='View footnote' class='footnote'>" + n + "</a>]";
+ spans[i].setAttribute("data-note", note);
+ }
noteholder.innerHTML +=
"<div class='footnote' id='_footnote_" + n + "'>" +
"<a href='#_footnoteref_" + n + "' title='Return to text'>" +
n + "</a>. " + note + "</div>";
- spans[i].innerHTML =
- "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
- "' title='View footnote' class='footnote'>" + n + "</a>]";
var id =spans[i].getAttribute("id");
if (id != null) refs["#"+id] = n;
}
@@ -561,13 +700,36 @@ footnotes: function () {
}
}
}
+},
+
+install: function(toclevels) {
+ var timerId;
+
+ function reinstall() {
+ asciidoc.footnotes();
+ if (toclevels) {
+ asciidoc.toc(toclevels);
+ }
+ }
+
+ function reinstallAndRemoveTimer() {
+ clearInterval(timerId);
+ reinstall();
+ }
+
+ timerId = setInterval(reinstall, 500);
+ if (document.addEventListener)
+ document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
+ else
+ window.onload = reinstallAndRemoveTimer;
}
}
+asciidoc.install();
/*]]>*/
</script>
</head>
-<body>
+<body class="manpage">
<div id="header">
<h1>
gitcore-tutorial(7) Manual Page
@@ -580,10 +742,13 @@ gitcore-tutorial(7) Manual Page
</div>
</div>
<div id="content">
+<div class="sect1">
<h2 id="_synopsis">SYNOPSIS</h2>
<div class="sectionbody">
<div class="paragraph"><p>git *</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph"><p>This tutorial explains how to use the "core" git commands to set up and
@@ -614,6 +779,8 @@ skip on your first reading.</td>
</tr></table>
</div>
</div>
+</div>
+<div class="sect1">
<h2 id="_creating_a_git_repository">Creating a git repository</h2>
<div class="sectionbody">
<div class="paragraph"><p>Creating a new git repository couldn&#8217;t be easier: all git repositories start
@@ -627,34 +794,34 @@ To start up, create a subdirectory for it, change into that
subdirectory, and initialize the git infrastructure with <em>git init</em>:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ mkdir git-tutorial
+<pre><code>$ mkdir git-tutorial
$ cd git-tutorial
-$ git init</tt></pre>
+$ git init</code></pre>
</div></div>
<div class="paragraph"><p>to which git will reply</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>Initialized empty Git repository in .git/</tt></pre>
+<pre><code>Initialized empty Git repository in .git/</code></pre>
</div></div>
<div class="paragraph"><p>which is just git&#8217;s way of saying that you haven&#8217;t been doing anything
-strange, and that it will have created a local <tt>.git</tt> directory setup for
-your new project. You will now have a <tt>.git</tt> directory, and you can
+strange, and that it will have created a local <code>.git</code> directory setup for
+your new project. You will now have a <code>.git</code> directory, and you can
inspect that with <em>ls</em>. For your new empty project, it should show you
three entries, among other things:</p></div>
<div class="ulist"><ul>
<li>
<p>
-a file called <tt>HEAD</tt>, that has <tt>ref: refs/heads/master</tt> in it.
+a file called <code>HEAD</code>, that has <code>ref: refs/heads/master</code> in it.
This is similar to a symbolic link and points at
- <tt>refs/heads/master</tt> relative to the <tt>HEAD</tt> file.
+ <code>refs/heads/master</code> relative to the <code>HEAD</code> file.
</p>
-<div class="paragraph"><p>Don&#8217;t worry about the fact that the file that the <tt>HEAD</tt> link points to
+<div class="paragraph"><p>Don&#8217;t worry about the fact that the file that the <code>HEAD</code> link points to
doesn&#8217;t even exist yet&#8201;&#8212;&#8201;you haven&#8217;t created the commit that will
-start your <tt>HEAD</tt> development branch yet.</p></div>
+start your <code>HEAD</code> development branch yet.</p></div>
</li>
<li>
<p>
-a subdirectory called <tt>objects</tt>, which will contain all the
+a subdirectory called <code>objects</code>, which will contain all the
objects of your project. You should never have any real reason to
look at the objects directly, but you might want to know that these
objects are what contains all the real <em>data</em> in your repository.
@@ -662,24 +829,24 @@ a subdirectory called <tt>objects</tt>, which will contain all the
</li>
<li>
<p>
-a subdirectory called <tt>refs</tt>, which contains references to objects.
+a subdirectory called <code>refs</code>, which contains references to objects.
</p>
</li>
</ul></div>
-<div class="paragraph"><p>In particular, the <tt>refs</tt> subdirectory will contain two other
-subdirectories, named <tt>heads</tt> and <tt>tags</tt> respectively. They do
+<div class="paragraph"><p>In particular, the <code>refs</code> subdirectory will contain two other
+subdirectories, named <code>heads</code> and <code>tags</code> respectively. They do
exactly what their names imply: they contain references to any number
of different <em>heads</em> of development (aka <em>branches</em>), and to any
<em>tags</em> that you have created to name specific versions in your
repository.</p></div>
-<div class="paragraph"><p>One note: the special <tt>master</tt> head is the default branch, which is
-why the <tt>.git/HEAD</tt> file was created points to it even if it
-doesn&#8217;t yet exist. Basically, the <tt>HEAD</tt> link is supposed to always
+<div class="paragraph"><p>One note: the special <code>master</code> head is the default branch, which is
+why the <code>.git/HEAD</code> file was created points to it even if it
+doesn&#8217;t yet exist. Basically, the <code>HEAD</code> link is supposed to always
point to the branch you are working on right now, and you always
-start out expecting to work on the <tt>master</tt> branch.</p></div>
+start out expecting to work on the <code>master</code> branch.</p></div>
<div class="paragraph"><p>However, this is only a convention, and you can name your branches
-anything you want, and don&#8217;t have to ever even <em>have</em> a <tt>master</tt>
-branch. A number of the git tools will assume that <tt>.git/HEAD</tt> is
+anything you want, and don&#8217;t have to ever even <em>have</em> a <code>master</code>
+branch. A number of the git tools will assume that <code>.git/HEAD</code> is
valid, though.</p></div>
<div class="admonitionblock">
<table><tr>
@@ -688,11 +855,11 @@ valid, though.</p></div>
</td>
<td class="content">An <em>object</em> is identified by its 160-bit SHA1 hash, aka <em>object name</em>,
and a reference to an object is always the 40-byte hex
-representation of that SHA1 name. The files in the <tt>refs</tt>
+representation of that SHA1 name. The files in the <code>refs</code>
subdirectory are expected to contain these hex references
-(usually with a final <tt>\n</tt> at the end), and you should thus
+(usually with a final <code>\n</code> at the end), and you should thus
expect to see a number of 41-byte files containing these
-references in these <tt>refs</tt> subdirectories when you actually start
+references in these <code>refs</code> subdirectories when you actually start
populating your tree.</td>
</tr></table>
</div>
@@ -708,6 +875,8 @@ after finishing this tutorial.</td>
<div class="paragraph"><p>You have now created your first git repository. Of course, since it&#8217;s
empty, that&#8217;s not very useful, so let&#8217;s start populating it with data.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_populating_a_git_repository">Populating a git repository</h2>
<div class="sectionbody">
<div class="paragraph"><p>We&#8217;ll keep this simple and stupid, so we&#8217;ll start off with populating a
@@ -717,8 +886,8 @@ in your git repository. We&#8217;ll start off with a few bad examples, just to
get a feel for how this works:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ echo "Hello World" &gt;hello
-$ echo "Silly example" &gt;example</tt></pre>
+<pre><code>$ echo "Hello World" &gt;hello
+$ echo "Silly example" &gt;example</code></pre>
</div></div>
<div class="paragraph"><p>you have now created two files in your working tree (aka <em>working directory</em>),
but to actually check in your hard work, you will have to go through two steps:</p></div>
@@ -740,12 +909,12 @@ to your working tree, you use the <em>git update-index</em> program. That
program normally just takes a list of filenames you want to update, but
to avoid trivial mistakes, it refuses to add new entries to the index
(or remove existing ones) unless you explicitly tell it that you&#8217;re
-adding a new entry with the <tt>--add</tt> flag (or removing an entry with the
-<tt>--remove</tt>) flag.</p></div>
+adding a new entry with the <code>--add</code> flag (or removing an entry with the
+<code>--remove</code>) flag.</p></div>
<div class="paragraph"><p>So to populate the index with the two files you just created, you can do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git update-index --add hello example</tt></pre>
+<pre><code>$ git update-index --add hello example</code></pre>
</div></div>
<div class="paragraph"><p>and you have now told git to track those two files.</p></div>
<div class="paragraph"><p>In fact, as you did that, if you now look into your object directory,
@@ -753,39 +922,39 @@ you&#8217;ll notice that git will have added two new objects to the object
database. If you did exactly the steps above, you should now be able to do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ ls .git/objects/??/*</tt></pre>
+<pre><code>$ ls .git/objects/??/*</code></pre>
</div></div>
<div class="paragraph"><p>and see two files:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238
-.git/objects/f2/4c74a2e500f5ee1332c86b94199f52b1d1d962</tt></pre>
+<pre><code>.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238
+.git/objects/f2/4c74a2e500f5ee1332c86b94199f52b1d1d962</code></pre>
</div></div>
-<div class="paragraph"><p>which correspond with the objects with names of <tt>557db...</tt> and
-<tt>f24c7...</tt> respectively.</p></div>
+<div class="paragraph"><p>which correspond with the objects with names of <code>557db...</code> and
+<code>f24c7...</code> respectively.</p></div>
<div class="paragraph"><p>If you want to, you can use <em>git cat-file</em> to look at those objects, but
you&#8217;ll have to use the object name, not the filename of the object:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238</tt></pre>
+<pre><code>$ git cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238</code></pre>
</div></div>
-<div class="paragraph"><p>where the <tt>-t</tt> tells <em>git cat-file</em> to tell you what the "type" of the
+<div class="paragraph"><p>where the <code>-t</code> tells <em>git cat-file</em> to tell you what the "type" of the
object is. git will tell you that you have a "blob" object (i.e., just a
regular file), and you can see the contents with</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git cat-file blob 557db03</tt></pre>
+<pre><code>$ git cat-file blob 557db03</code></pre>
</div></div>
-<div class="paragraph"><p>which will print out "Hello World". The object <tt>557db03</tt> is nothing
-more than the contents of your file <tt>hello</tt>.</p></div>
+<div class="paragraph"><p>which will print out "Hello World". The object <code>557db03</code> is nothing
+more than the contents of your file <code>hello</code>.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
-<td class="content">Don&#8217;t confuse that object with the file <tt>hello</tt> itself. The
+<td class="content">Don&#8217;t confuse that object with the file <code>hello</code> itself. The
object is literally just those specific <strong>contents</strong> of the file, and
-however much you later change the contents in file <tt>hello</tt>, the object
+however much you later change the contents in file <code>hello</code>, the object
we just looked at will never change. Objects are immutable.</td>
</tr></table>
</div>
@@ -805,7 +974,7 @@ names is not something you&#8217;d normally want to do. The above digression
was just to show that <em>git update-index</em> did something magical, and
actually saved away the contents of your files into the git object
database.</p></div>
-<div class="paragraph"><p>Updating the index did something else too: it created a <tt>.git/index</tt>
+<div class="paragraph"><p>Updating the index did something else too: it created a <code>.git/index</code>
file. This is the index that describes your current working tree, and
something you should be very aware of. Again, you normally never worry
about the index file itself, but you should be aware of the fact that
@@ -814,53 +983,55 @@ you&#8217;ve only <strong>told</strong> git about them.</p></div>
<div class="paragraph"><p>However, since git knows about them, you can now start using some of the
most basic git commands to manipulate the files or look at their status.</p></div>
<div class="paragraph"><p>In particular, let&#8217;s not even check in the two files into git yet, we&#8217;ll
-start off by adding another line to <tt>hello</tt> first:</p></div>
+start off by adding another line to <code>hello</code> first:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ echo "It's a new day for git" &gt;&gt;hello</tt></pre>
+<pre><code>$ echo "It's a new day for git" &gt;&gt;hello</code></pre>
</div></div>
-<div class="paragraph"><p>and you can now, since you told git about the previous state of <tt>hello</tt>, ask
+<div class="paragraph"><p>and you can now, since you told git about the previous state of <code>hello</code>, ask
git what has changed in the tree compared to your old index, using the
<em>git diff-files</em> command:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git diff-files</tt></pre>
+<pre><code>$ git diff-files</code></pre>
</div></div>
<div class="paragraph"><p>Oops. That wasn&#8217;t very readable. It just spit out its own internal
version of a <em>diff</em>, but that internal version really just tells you
that it has noticed that "hello" has been modified, and that the old object
contents it had have been replaced with something else.</p></div>
<div class="paragraph"><p>To make it readable, we can tell <em>git diff-files</em> to output the
-differences as a patch, using the <tt>-p</tt> flag:</p></div>
+differences as a patch, using the <code>-p</code> flag:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git diff-files -p
+<pre><code>$ git diff-files -p
diff --git a/hello b/hello
index 557db03..263414f 100644
--- a/hello
+++ b/hello
@@ -1 +1,2 @@
Hello World
-+It's a new day for git</tt></pre>
++It's a new day for git</code></pre>
</div></div>
-<div class="paragraph"><p>i.e. the diff of the change we caused by adding another line to <tt>hello</tt>.</p></div>
+<div class="paragraph"><p>i.e. the diff of the change we caused by adding another line to <code>hello</code>.</p></div>
<div class="paragraph"><p>In other words, <em>git diff-files</em> always shows us the difference between
what is recorded in the index, and what is currently in the working
tree. That&#8217;s very useful.</p></div>
-<div class="paragraph"><p>A common shorthand for <tt>git diff-files -p</tt> is to just write <tt>git
-diff</tt>, which will do the same thing.</p></div>
+<div class="paragraph"><p>A common shorthand for <code>git diff-files -p</code> is to just write <code>git
+diff</code>, which will do the same thing.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git diff
+<pre><code>$ git diff
diff --git a/hello b/hello
index 557db03..263414f 100644
--- a/hello
+++ b/hello
@@ -1 +1,2 @@
Hello World
-+It's a new day for git</tt></pre>
++It's a new day for git</code></pre>
</div></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_committing_git_state">Committing git state</h2>
<div class="sectionbody">
<div class="paragraph"><p>Now, we want to go to the next stage in git, which is to take the files
@@ -869,25 +1040,25 @@ that in two phases: creating a <em>tree</em> object, and committing that <em>tre
object as a <em>commit</em> object together with an explanation of what the
tree was all about, along with information of how we came to that state.</p></div>
<div class="paragraph"><p>Creating a tree object is trivial, and is done with <em>git write-tree</em>.
-There are no options or other input: <tt>git write-tree</tt> will take the
+There are no options or other input: <code>git write-tree</code> will take the
current index state, and write an object that describes that whole
index. In other words, we&#8217;re now tying together all the different
filenames with their contents (and their permissions), and we&#8217;re
creating the equivalent of a git "directory" object:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git write-tree</tt></pre>
+<pre><code>$ git write-tree</code></pre>
</div></div>
<div class="paragraph"><p>and this will just output the name of the resulting tree, in this case
(if you have done exactly as I&#8217;ve described) it should be</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>8988da15d077d4829fc51d8544c097def6644dbb</tt></pre>
+<pre><code>8988da15d077d4829fc51d8544c097def6644dbb</code></pre>
</div></div>
<div class="paragraph"><p>which is another incomprehensible object name. Again, if you want to,
-you can use <tt>git cat-file -t 8988d...</tt> to see that this time the object
+you can use <code>git cat-file -t 8988d...</code> to see that this time the object
is not a "blob" object, but a "tree" object (you can also use
-<tt>git cat-file</tt> to actually output the raw object contents, but you&#8217;ll see
+<code>git cat-file</code> to actually output the raw object contents, but you&#8217;ll see
mainly a binary mess, so that&#8217;s less interesting).</p></div>
<div class="paragraph"><p>However&#8201;&#8212;&#8201;normally you&#8217;d never use <em>git write-tree</em> on its own, because
normally you always commit a tree into a commit object using the
@@ -900,37 +1071,39 @@ ever in this new repository, and it has no parents, we only need to pass in
the object name of the tree. However, <em>git commit-tree</em> also wants to get a
commit message on its standard input, and it will write out the resulting
object name for the commit to its standard output.</p></div>
-<div class="paragraph"><p>And this is where we create the <tt>.git/refs/heads/master</tt> file
-which is pointed at by <tt>HEAD</tt>. This file is supposed to contain
+<div class="paragraph"><p>And this is where we create the <code>.git/refs/heads/master</code> file
+which is pointed at by <code>HEAD</code>. This file is supposed to contain
the reference to the top-of-tree of the master branch, and since
that&#8217;s exactly what <em>git commit-tree</em> spits out, we can do this
all with a sequence of simple shell commands:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ tree=$(git write-tree)
+<pre><code>$ tree=$(git write-tree)
$ commit=$(echo 'Initial commit' | git commit-tree $tree)
-$ git update-ref HEAD $commit</tt></pre>
+$ git update-ref HEAD $commit</code></pre>
</div></div>
<div class="paragraph"><p>In this case this creates a totally new commit that is not related to
anything else. Normally you do this only <strong>once</strong> for a project ever, and
all later commits will be parented on top of an earlier commit.</p></div>
<div class="paragraph"><p>Again, normally you&#8217;d never actually do this by hand. There is a
-helpful script called <tt>git commit</tt> that will do all of this for you. So
-you could have just written <tt>git commit</tt>
+helpful script called <code>git commit</code> that will do all of this for you. So
+you could have just written <code>git commit</code>
instead, and it would have done the above magic scripting for you.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_making_a_change">Making a change</h2>
<div class="sectionbody">
-<div class="paragraph"><p>Remember how we did the <em>git update-index</em> on file <tt>hello</tt> and then we
-changed <tt>hello</tt> afterward, and could compare the new state of <tt>hello</tt> with the
+<div class="paragraph"><p>Remember how we did the <em>git update-index</em> on file <code>hello</code> and then we
+changed <code>hello</code> afterward, and could compare the new state of <code>hello</code> with the
state we saved in the index file?</p></div>
<div class="paragraph"><p>Further, remember how I said that <em>git write-tree</em> writes the contents
of the <strong>index</strong> file to the tree, and thus what we just committed was in
-fact the <strong>original</strong> contents of the file <tt>hello</tt>, not the new ones. We did
+fact the <strong>original</strong> contents of the file <code>hello</code>, not the new ones. We did
that on purpose, to show the difference between the index state, and the
state in the working tree, and how they don&#8217;t have to match, even
when we commit things.</p></div>
-<div class="paragraph"><p>As before, if we do <tt>git diff-files -p</tt> in our git-tutorial project,
+<div class="paragraph"><p>As before, if we do <code>git diff-files -p</code> in our git-tutorial project,
we&#8217;ll still see the same difference we saw last time: the index file
hasn&#8217;t changed by the act of committing anything. However, now that we
have committed something, we can also learn to use a new command:
@@ -944,9 +1117,9 @@ didn&#8217;t have anything to diff against.</p></div>
<div class="paragraph"><p>But now we can do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git diff-index -p HEAD</tt></pre>
+<pre><code>$ git diff-index -p HEAD</code></pre>
</div></div>
-<div class="paragraph"><p>(where <tt>-p</tt> has the same meaning as it did in <em>git diff-files</em>), and it
+<div class="paragraph"><p>(where <code>-p</code> has the same meaning as it did in <em>git diff-files</em>), and it
will show us the same difference, but for a totally different reason.
Now we&#8217;re comparing the working tree not against the index file,
but against the tree we just wrote. It just so happens that those two
@@ -955,14 +1128,14 @@ are obviously the same, so we get the same result.</p></div>
it with</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git diff HEAD</tt></pre>
+<pre><code>$ git diff HEAD</code></pre>
</div></div>
<div class="paragraph"><p>which ends up doing the above for you.</p></div>
<div class="paragraph"><p>In other words, <em>git diff-index</em> normally compares a tree against the
-working tree, but when given the <tt>--cached</tt> flag, it is told to
+working tree, but when given the <code>--cached</code> flag, it is told to
instead compare against just the index cache contents, and ignore the
current working tree state entirely. Since we just wrote the index
-file to HEAD, doing <tt>git diff-index --cached -p HEAD</tt> should thus return
+file to HEAD, doing <code>git diff-index --cached -p HEAD</code> should thus return
an empty set of differences, and that&#8217;s exactly what it does.</p></div>
<div class="admonitionblock">
<table><tr>
@@ -974,7 +1147,7 @@ an empty set of differences, and that&#8217;s exactly what it does.</p></div>
comparisons, and saying that it compares a tree against the working
tree is thus not strictly accurate. In particular, the list of
files to compare (the "meta-data") <strong>always</strong> comes from the index file,
-regardless of whether the <tt>--cached</tt> flag is used or not. The <tt>--cached</tt>
+regardless of whether the <code>--cached</code> flag is used or not. The <code>--cached</code>
flag really only determines whether the file <strong>contents</strong> to be compared
come from the working tree or not.</p></div>
<div class="paragraph"><p>This is not hard to understand, as soon as you realize that git simply
@@ -993,25 +1166,25 @@ work through the index file, so the first thing we need to do is to
update the index cache:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git update-index hello</tt></pre>
+<pre><code>$ git update-index hello</code></pre>
</div></div>
-<div class="paragraph"><p>(note how we didn&#8217;t need the <tt>--add</tt> flag this time, since git knew
+<div class="paragraph"><p>(note how we didn&#8217;t need the <code>--add</code> flag this time, since git knew
about the file already).</p></div>
<div class="paragraph"><p>Note what happens to the different <em>git diff-&#42;</em> versions here.
-After we&#8217;ve updated <tt>hello</tt> in the index, <tt>git diff-files -p</tt> now shows no
-differences, but <tt>git diff-index -p HEAD</tt> still <strong>does</strong> show that the
+After we&#8217;ve updated <code>hello</code> in the index, <code>git diff-files -p</code> now shows no
+differences, but <code>git diff-index -p HEAD</code> still <strong>does</strong> show that the
current state is different from the state we committed. In fact, now
-<em>git diff-index</em> shows the same difference whether we use the <tt>--cached</tt>
+<em>git diff-index</em> shows the same difference whether we use the <code>--cached</code>
flag or not, since now the index is coherent with the working tree.</p></div>
-<div class="paragraph"><p>Now, since we&#8217;ve updated <tt>hello</tt> in the index, we can commit the new
+<div class="paragraph"><p>Now, since we&#8217;ve updated <code>hello</code> in the index, we can commit the new
version. We could do it by writing the tree by hand again, and
-committing the tree (this time we&#8217;d have to use the <tt>-p HEAD</tt> flag to
+committing the tree (this time we&#8217;d have to use the <code>-p HEAD</code> flag to
tell commit that the HEAD was the <strong>parent</strong> of the new commit, and that
this wasn&#8217;t an initial commit any more), but you&#8217;ve done that once
already, so let&#8217;s just use the helpful script this time:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git commit</tt></pre>
+<pre><code>$ git commit</code></pre>
</div></div>
<div class="paragraph"><p>which starts an editor for you to write the commit message and tells you
a bit about what you have done.</p></div>
@@ -1019,14 +1192,16 @@ a bit about what you have done.</p></div>
will be pruned out, and the rest will be used as the commit message for
the change. If you decide you don&#8217;t want to commit anything after all at
this point (you can continue to edit things and update the index), you
-can just leave an empty message. Otherwise <tt>git commit</tt> will commit
+can just leave an empty message. Otherwise <code>git commit</code> will commit
the change for you.</p></div>
<div class="paragraph"><p>You&#8217;ve now made your first real git commit. And if you&#8217;re interested in
-looking at what <tt>git commit</tt> really does, feel free to investigate:
+looking at what <code>git commit</code> really does, feel free to investigate:
it&#8217;s a few very simple shell scripts to generate the helpful (?) commit
message headers, and a few one-liners that actually do the
commit itself (<em>git commit</em>).</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_inspecting_changes">Inspecting Changes</h2>
<div class="sectionbody">
<div class="paragraph"><p>While creating changes is useful, it&#8217;s even more useful if you can tell
@@ -1039,10 +1214,10 @@ of that commit itself, and show the difference directly. Thus, to get
the same diff that we&#8217;ve already seen several times, we can now do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git diff-tree -p HEAD</tt></pre>
+<pre><code>$ git diff-tree -p HEAD</code></pre>
</div></div>
-<div class="paragraph"><p>(again, <tt>-p</tt> means to show the difference as a human-readable patch),
-and it will show what the last commit (in <tt>HEAD</tt>) actually changed.</p></div>
+<div class="paragraph"><p>(again, <code>-p</code> means to show the difference as a human-readable patch),
+and it will show what the last commit (in <code>HEAD</code>) actually changed.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
@@ -1053,7 +1228,7 @@ and it will show what the last commit (in <tt>HEAD</tt>) actually changed.</p></
various <em>diff-&#42;</em> commands compare things.</p></div>
<div class="literalblock">
<div class="content">
-<pre><tt> diff-tree
+<pre><code> diff-tree
+----+
| |
| |
@@ -1080,12 +1255,12 @@ diff-index | V
+-----------+
| Working |
| Directory |
- +-----------+</tt></pre>
+ +-----------+</code></pre>
</div></div>
</td>
</tr></table>
</div>
-<div class="paragraph"><p>More interestingly, you can also give <em>git diff-tree</em> the <tt>--pretty</tt> flag,
+<div class="paragraph"><p>More interestingly, you can also give <em>git diff-tree</em> the <code>--pretty</code> flag,
which tells it to also show the commit message and author and date of the
commit, and you can tell it to show a whole series of diffs.
Alternatively, you can tell it to be "silent", and not show the diffs at
@@ -1099,14 +1274,14 @@ activities.</p></div>
can do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git log</tt></pre>
+<pre><code>$ git log</code></pre>
</div></div>
<div class="paragraph"><p>which shows just the log messages, or if we want to see the log together
with the associated patches use the more complex (and much more
powerful)</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git whatchanged -p</tt></pre>
+<pre><code>$ git whatchanged -p</code></pre>
</div></div>
<div class="paragraph"><p>and you will see exactly what has changed in the repository over its
short history.</p></div>
@@ -1118,7 +1293,7 @@ short history.</p></div>
<td class="content">When using the above two commands, the initial commit will be shown.
If this is a problem because it is huge, you can hide it by setting
the log.showroot configuration variable to false. Having this, you
-can still show it for each command just adding the <tt>--root</tt> option,
+can still show it for each command just adding the <code>--root</code> option,
which is a flag for <em>git diff-tree</em> accepted by both commands.</td>
</tr></table>
</div>
@@ -1135,22 +1310,24 @@ and &#8216;git-commit&#8217;.</td>
</tr></table>
</div>
</div>
+</div>
+<div class="sect1">
<h2 id="_tagging_a_version">Tagging a version</h2>
<div class="sectionbody">
<div class="paragraph"><p>In git, there are two kinds of tags, a "light" one, and an "annotated tag".</p></div>
<div class="paragraph"><p>A "light" tag is technically nothing more than a branch, except we put
-it in the <tt>.git/refs/tags/</tt> subdirectory instead of calling it a <tt>head</tt>.
+it in the <code>.git/refs/tags/</code> subdirectory instead of calling it a <code>head</code>.
So the simplest form of tag involves nothing more than</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git tag my-first-tag</tt></pre>
+<pre><code>$ git tag my-first-tag</code></pre>
</div></div>
-<div class="paragraph"><p>which just writes the current <tt>HEAD</tt> into the <tt>.git/refs/tags/my-first-tag</tt>
+<div class="paragraph"><p>which just writes the current <code>HEAD</code> into the <code>.git/refs/tags/my-first-tag</code>
file, after which point you can then use this symbolic name for that
particular state. You can, for example, do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git diff my-first-tag</tt></pre>
+<pre><code>$ git diff my-first-tag</code></pre>
</div></div>
<div class="paragraph"><p>to diff your current state against that tag which at this point will
obviously be an empty diff, but if you continue to develop and commit
@@ -1160,27 +1337,29 @@ since you tagged it.</p></div>
pointer to the state you want to tag, but also a small tag name and
message, along with optionally a PGP signature that says that yes,
you really did
-that tag. You create these annotated tags with either the <tt>-a</tt> or
-<tt>-s</tt> flag to <em>git tag</em>:</p></div>
+that tag. You create these annotated tags with either the <code>-a</code> or
+<code>-s</code> flag to <em>git tag</em>:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git tag -s &lt;tagname&gt;</tt></pre>
+<pre><code>$ git tag -s &lt;tagname&gt;</code></pre>
</div></div>
-<div class="paragraph"><p>which will sign the current <tt>HEAD</tt> (but you can also give it another
+<div class="paragraph"><p>which will sign the current <code>HEAD</code> (but you can also give it another
argument that specifies the thing to tag, e.g., you could have tagged the
-current <tt>mybranch</tt> point by using <tt>git tag &lt;tagname&gt; mybranch</tt>).</p></div>
+current <code>mybranch</code> point by using <code>git tag &lt;tagname&gt; mybranch</code>).</p></div>
<div class="paragraph"><p>You normally only do signed tags for major releases or things
like that, while the light-weight tags are useful for any marking you
want to do&#8201;&#8212;&#8201;any time you decide that you want to remember a certain
point, just create a private tag for it, and you have a nice symbolic
name for the state at that point.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_copying_repositories">Copying repositories</h2>
<div class="sectionbody">
<div class="paragraph"><p>git repositories are normally totally self-sufficient and relocatable.
Unlike CVS, for example, there is no separate notion of
"repository" and "working tree". A git repository normally <strong>is</strong> the
-working tree, with the local git information hidden in the <tt>.git</tt>
+working tree, with the local git information hidden in the <code>.git</code>
subdirectory. There is nothing else. What you see is what you got.</p></div>
<div class="admonitionblock">
<table><tr>
@@ -1204,7 +1383,7 @@ if you grow bored with the tutorial repository you created (or you&#8217;ve
</p>
<div class="listingblock">
<div class="content">
-<pre><tt>$ rm -rf git-tutorial</tt></pre>
+<pre><code>$ rm -rf git-tutorial</code></pre>
</div></div>
<div class="paragraph"><p>and it will be gone. There&#8217;s no external repository, and there&#8217;s no
history outside the project you created.</p></div>
@@ -1215,15 +1394,15 @@ if you want to move or duplicate a git repository, you can do so. There
is <em>git clone</em> command, but if all you want to do is just to
create a copy of your repository (with all the full history that
went along with it), you can do so with a regular
- <tt>cp -a git-tutorial new-git-tutorial</tt>.
+ <code>cp -a git-tutorial new-git-tutorial</code>.
</p>
<div class="paragraph"><p>Note that when you&#8217;ve moved or copied a git repository, your git index
file (which caches various information, notably some of the "stat"
information for the files involved) will likely need to be refreshed.
-So after you do a <tt>cp -a</tt> to create a new copy, you&#8217;ll want to do</p></div>
+So after you do a <code>cp -a</code> to create a new copy, you&#8217;ll want to do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git update-index --refresh</tt></pre>
+<pre><code>$ git update-index --refresh</code></pre>
</div></div>
<div class="paragraph"><p>in the new repository to make sure that the index file is up-to-date.</p></div>
</li>
@@ -1238,45 +1417,45 @@ known state (you don&#8217;t know <strong>what</strong> they&#8217;ve done and n
so usually you&#8217;ll precede the <em>git update-index</em> with a</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git read-tree --reset HEAD
-$ git update-index --refresh</tt></pre>
+<pre><code>$ git read-tree --reset HEAD
+$ git update-index --refresh</code></pre>
</div></div>
-<div class="paragraph"><p>which will force a total index re-build from the tree pointed to by <tt>HEAD</tt>.
-It resets the index contents to <tt>HEAD</tt>, and then the <em>git update-index</em>
+<div class="paragraph"><p>which will force a total index re-build from the tree pointed to by <code>HEAD</code>.
+It resets the index contents to <code>HEAD</code>, and then the <em>git update-index</em>
makes sure to match up all index entries with the checked-out files.
If the original repository had uncommitted changes in its
-working tree, <tt>git update-index --refresh</tt> notices them and
+working tree, <code>git update-index --refresh</code> notices them and
tells you they need to be updated.</p></div>
<div class="paragraph"><p>The above can also be written as simply</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git reset</tt></pre>
+<pre><code>$ git reset</code></pre>
</div></div>
<div class="paragraph"><p>and in fact a lot of the common git command combinations can be scripted
-with the <tt>git xyz</tt> interfaces. You can learn things by just looking
-at what the various git scripts do. For example, <tt>git reset</tt> used to be
+with the <code>git xyz</code> interfaces. You can learn things by just looking
+at what the various git scripts do. For example, <code>git reset</code> used to be
the above two lines implemented in <em>git reset</em>, but some things like
<em>git status</em> and <em>git commit</em> are slightly more complex scripts around
the basic git commands.</p></div>
<div class="paragraph"><p>Many (most?) public remote repositories will not contain any of
the checked out files or even an index file, and will <strong>only</strong> contain the
actual core git files. Such a repository usually doesn&#8217;t even have the
-<tt>.git</tt> subdirectory, but has all the git files directly in the
+<code>.git</code> subdirectory, but has all the git files directly in the
repository.</p></div>
<div class="paragraph"><p>To create your own local live copy of such a "raw" git repository, you&#8217;d
first create your own subdirectory for the project, and then copy the
-raw repository contents into the <tt>.git</tt> directory. For example, to
+raw repository contents into the <code>.git</code> directory. For example, to
create your own copy of the git repository, you&#8217;d do the following</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ mkdir my-git
+<pre><code>$ mkdir my-git
$ cd my-git
-$ rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git</tt></pre>
+$ rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git</code></pre>
</div></div>
<div class="paragraph"><p>followed by</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git read-tree HEAD</tt></pre>
+<pre><code>$ git read-tree HEAD</code></pre>
</div></div>
<div class="paragraph"><p>to populate the index. However, now you have populated the index, and
you have all the git internal files, but you will notice that you don&#8217;t
@@ -1284,45 +1463,47 @@ actually have any of the working tree files to work on. To get
those, you&#8217;d check them out with</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout-index -u -a</tt></pre>
+<pre><code>$ git checkout-index -u -a</code></pre>
</div></div>
-<div class="paragraph"><p>where the <tt>-u</tt> flag means that you want the checkout to keep the index
+<div class="paragraph"><p>where the <code>-u</code> flag means that you want the checkout to keep the index
up-to-date (so that you don&#8217;t have to refresh it afterward), and the
-<tt>-a</tt> flag means "check out all files" (if you have a stale copy or an
-older version of a checked out tree you may also need to add the <tt>-f</tt>
+<code>-a</code> flag means "check out all files" (if you have a stale copy or an
+older version of a checked out tree you may also need to add the <code>-f</code>
flag first, to tell <em>git checkout-index</em> to <strong>force</strong> overwriting of any old
files).</p></div>
<div class="paragraph"><p>Again, this can all be simplified with</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git clone rsync://rsync.kernel.org/pub/scm/git/git.git/ my-git
+<pre><code>$ git clone rsync://rsync.kernel.org/pub/scm/git/git.git/ my-git
$ cd my-git
-$ git checkout</tt></pre>
+$ git checkout</code></pre>
</div></div>
<div class="paragraph"><p>which will end up doing all of the above for you.</p></div>
<div class="paragraph"><p>You have now successfully copied somebody else&#8217;s (mine) remote
repository, and checked it out.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_creating_a_new_branch">Creating a new branch</h2>
<div class="sectionbody">
<div class="paragraph"><p>Branches in git are really nothing more than pointers into the git
-object database from within the <tt>.git/refs/</tt> subdirectory, and as we
-already discussed, the <tt>HEAD</tt> branch is nothing but a symlink to one of
+object database from within the <code>.git/refs/</code> subdirectory, and as we
+already discussed, the <code>HEAD</code> branch is nothing but a symlink to one of
these object pointers.</p></div>
<div class="paragraph"><p>You can at any time create a new branch by just picking an arbitrary
point in the project history, and just writing the SHA1 name of that
-object into a file under <tt>.git/refs/heads/</tt>. You can use any filename you
+object into a file under <code>.git/refs/heads/</code>. You can use any filename you
want (and indeed, subdirectories), but the convention is that the
-"normal" branch is called <tt>master</tt>. That&#8217;s just a convention, though,
+"normal" branch is called <code>master</code>. That&#8217;s just a convention, though,
and nothing enforces it.</p></div>
<div class="paragraph"><p>To show that as an example, let&#8217;s go back to the git-tutorial repository we
used earlier, and create a branch in it. You do that by simply just
saying that you want to check out a new branch:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout -b mybranch</tt></pre>
+<pre><code>$ git checkout -b mybranch</code></pre>
</div></div>
-<div class="paragraph"><p>will create a new branch based at the current <tt>HEAD</tt> position, and switch
+<div class="paragraph"><p>will create a new branch based at the current <code>HEAD</code> position, and switch
to it.</p></div>
<div class="admonitionblock">
<table><tr>
@@ -1331,82 +1512,84 @@ to it.</p></div>
</td>
<td class="content">
<div class="paragraph"><p>If you make the decision to start your new branch at some
-other point in the history than the current <tt>HEAD</tt>, you can do so by
+other point in the history than the current <code>HEAD</code>, you can do so by
just telling <em>git checkout</em> what the base of the checkout would be.
In other words, if you have an earlier tag or branch, you&#8217;d just do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout -b mybranch earlier-commit</tt></pre>
+<pre><code>$ git checkout -b mybranch earlier-commit</code></pre>
</div></div>
-<div class="paragraph"><p>and it would create the new branch <tt>mybranch</tt> at the earlier commit,
+<div class="paragraph"><p>and it would create the new branch <code>mybranch</code> at the earlier commit,
and check out the state at that time.</p></div>
</td>
</tr></table>
</div>
-<div class="paragraph"><p>You can always just jump back to your original <tt>master</tt> branch by doing</p></div>
+<div class="paragraph"><p>You can always just jump back to your original <code>master</code> branch by doing</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout master</tt></pre>
+<pre><code>$ git checkout master</code></pre>
</div></div>
<div class="paragraph"><p>(or any other branch-name, for that matter) and if you forget which
branch you happen to be on, a simple</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ cat .git/HEAD</tt></pre>
+<pre><code>$ cat .git/HEAD</code></pre>
</div></div>
<div class="paragraph"><p>will tell you where it&#8217;s pointing. To get the list of branches
you have, you can say</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git branch</tt></pre>
+<pre><code>$ git branch</code></pre>
</div></div>
-<div class="paragraph"><p>which used to be nothing more than a simple script around <tt>ls .git/refs/heads</tt>.
+<div class="paragraph"><p>which used to be nothing more than a simple script around <code>ls .git/refs/heads</code>.
There will be an asterisk in front of the branch you are currently on.</p></div>
<div class="paragraph"><p>Sometimes you may wish to create a new branch <em>without</em> actually
checking it out and switching to it. If so, just use the command</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git branch &lt;branchname&gt; [startingpoint]</tt></pre>
+<pre><code>$ git branch &lt;branchname&gt; [startingpoint]</code></pre>
</div></div>
<div class="paragraph"><p>which will simply <em>create</em> the branch, but will not do anything further.
You can then later&#8201;&#8212;&#8201;once you decide that you want to actually develop
on that branch&#8201;&#8212;&#8201;switch to that branch with a regular <em>git checkout</em>
with the branchname as the argument.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_merging_two_branches">Merging two branches</h2>
<div class="sectionbody">
<div class="paragraph"><p>One of the ideas of having a branch is that you do some (possibly
experimental) work in it, and eventually merge it back to the main
-branch. So assuming you created the above <tt>mybranch</tt> that started out
-being the same as the original <tt>master</tt> branch, let&#8217;s make sure we&#8217;re in
+branch. So assuming you created the above <code>mybranch</code> that started out
+being the same as the original <code>master</code> branch, let&#8217;s make sure we&#8217;re in
that branch, and do some work there.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout mybranch
+<pre><code>$ git checkout mybranch
$ echo "Work, work, work" &gt;&gt;hello
-$ git commit -m "Some work." -i hello</tt></pre>
+$ git commit -m "Some work." -i hello</code></pre>
</div></div>
-<div class="paragraph"><p>Here, we just added another line to <tt>hello</tt>, and we used a shorthand for
-doing both <tt>git update-index hello</tt> and <tt>git commit</tt> by just giving the
-filename directly to <tt>git commit</tt>, with an <tt>-i</tt> flag (it tells
+<div class="paragraph"><p>Here, we just added another line to <code>hello</code>, and we used a shorthand for
+doing both <code>git update-index hello</code> and <code>git commit</code> by just giving the
+filename directly to <code>git commit</code>, with an <code>-i</code> flag (it tells
git to <em>include</em> that file in addition to what you have done to
-the index file so far when making the commit). The <tt>-m</tt> flag is to give the
+the index file so far when making the commit). The <code>-m</code> flag is to give the
commit log message from the command line.</p></div>
<div class="paragraph"><p>Now, to make it a bit more interesting, let&#8217;s assume that somebody else
does some work in the original branch, and simulate that by going back
to the master branch, and editing the same file differently there:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout master</tt></pre>
+<pre><code>$ git checkout master</code></pre>
</div></div>
-<div class="paragraph"><p>Here, take a moment to look at the contents of <tt>hello</tt>, and notice how they
-don&#8217;t contain the work we just did in <tt>mybranch</tt>&#8201;&#8212;&#8201;because that work
-hasn&#8217;t happened in the <tt>master</tt> branch at all. Then do</p></div>
+<div class="paragraph"><p>Here, take a moment to look at the contents of <code>hello</code>, and notice how they
+don&#8217;t contain the work we just did in <code>mybranch</code>&#8201;&#8212;&#8201;because that work
+hasn&#8217;t happened in the <code>master</code> branch at all. Then do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ echo "Play, play, play" &gt;&gt;hello
+<pre><code>$ echo "Play, play, play" &gt;&gt;hello
$ echo "Lots of fun" &gt;&gt;example
-$ git commit -m "Some fun." -i hello example</tt></pre>
+$ git commit -m "Some fun." -i hello example</code></pre>
</div></div>
<div class="paragraph"><p>since the master branch is obviously in a much better mood.</p></div>
<div class="paragraph"><p>Now, you&#8217;ve got two branches, and you decide that you want to merge the
@@ -1414,83 +1597,83 @@ work done. Before we do that, let&#8217;s introduce a cool graphical tool that
helps you view what&#8217;s going on:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ gitk --all</tt></pre>
+<pre><code>$ gitk --all</code></pre>
</div></div>
-<div class="paragraph"><p>will show you graphically both of your branches (that&#8217;s what the <tt>--all</tt>
-means: normally it will just show you your current <tt>HEAD</tt>) and their
+<div class="paragraph"><p>will show you graphically both of your branches (that&#8217;s what the <code>--all</code>
+means: normally it will just show you your current <code>HEAD</code>) and their
histories. You can also see exactly how they came to be from a common
source.</p></div>
-<div class="paragraph"><p>Anyway, let&#8217;s exit <em>gitk</em> (<tt>^Q</tt> or the File menu), and decide that we want
-to merge the work we did on the <tt>mybranch</tt> branch into the <tt>master</tt>
-branch (which is currently our <tt>HEAD</tt> too). To do that, there&#8217;s a nice
+<div class="paragraph"><p>Anyway, let&#8217;s exit <em>gitk</em> (<code>^Q</code> or the File menu), and decide that we want
+to merge the work we did on the <code>mybranch</code> branch into the <code>master</code>
+branch (which is currently our <code>HEAD</code> too). To do that, there&#8217;s a nice
script called <em>git merge</em>, which wants to know which branches you want
to resolve and what the merge is all about:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git merge -m "Merge work in mybranch" mybranch</tt></pre>
+<pre><code>$ git merge -m "Merge work in mybranch" mybranch</code></pre>
</div></div>
<div class="paragraph"><p>where the first argument is going to be used as the commit message if
the merge can be resolved automatically.</p></div>
<div class="paragraph"><p>Now, in this case we&#8217;ve intentionally created a situation where the
merge will need to be fixed up by hand, though, so git will do as much
-of it as it can automatically (which in this case is just merge the <tt>example</tt>
-file, which had no differences in the <tt>mybranch</tt> branch), and say:</p></div>
+of it as it can automatically (which in this case is just merge the <code>example</code>
+file, which had no differences in the <code>mybranch</code> branch), and say:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt> Auto-merging hello
+<pre><code> Auto-merging hello
CONFLICT (content): Merge conflict in hello
- Automatic merge failed; fix conflicts and then commit the result.</tt></pre>
+ Automatic merge failed; fix conflicts and then commit the result.</code></pre>
</div></div>
<div class="paragraph"><p>It tells you that it did an "Automatic merge", which
-failed due to conflicts in <tt>hello</tt>.</p></div>
-<div class="paragraph"><p>Not to worry. It left the (trivial) conflict in <tt>hello</tt> in the same form you
+failed due to conflicts in <code>hello</code>.</p></div>
+<div class="paragraph"><p>Not to worry. It left the (trivial) conflict in <code>hello</code> in the same form you
should already be well used to if you&#8217;ve ever used CVS, so let&#8217;s just
-open <tt>hello</tt> in our editor (whatever that may be), and fix it up somehow.
-I&#8217;d suggest just making it so that <tt>hello</tt> contains all four lines:</p></div>
+open <code>hello</code> in our editor (whatever that may be), and fix it up somehow.
+I&#8217;d suggest just making it so that <code>hello</code> contains all four lines:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>Hello World
+<pre><code>Hello World
It's a new day for git
Play, play, play
-Work, work, work</tt></pre>
+Work, work, work</code></pre>
</div></div>
<div class="paragraph"><p>and once you&#8217;re happy with your manual merge, just do a</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git commit -i hello</tt></pre>
+<pre><code>$ git commit -i hello</code></pre>
</div></div>
<div class="paragraph"><p>which will very loudly warn you that you&#8217;re now committing a merge
(which is correct, so never mind), and you can write a small merge
message about your adventures in <em>git merge</em>-land.</p></div>
-<div class="paragraph"><p>After you&#8217;re done, start up <tt>gitk --all</tt> to see graphically what the
-history looks like. Notice that <tt>mybranch</tt> still exists, and you can
+<div class="paragraph"><p>After you&#8217;re done, start up <code>gitk --all</code> to see graphically what the
+history looks like. Notice that <code>mybranch</code> still exists, and you can
switch to it, and continue to work with it if you want to. The
-<tt>mybranch</tt> branch will not contain the merge, but next time you merge it
-from the <tt>master</tt> branch, git will know how you merged it, so you&#8217;ll not
+<code>mybranch</code> branch will not contain the merge, but next time you merge it
+from the <code>master</code> branch, git will know how you merged it, so you&#8217;ll not
have to do <em>that</em> merge again.</p></div>
<div class="paragraph"><p>Another useful tool, especially if you do not always work in X-Window
-environment, is <tt>git show-branch</tt>.</p></div>
+environment, is <code>git show-branch</code>.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git show-branch --topo-order --more=1 master mybranch
+<pre><code>$ git show-branch --topo-order --more=1 master mybranch
* [master] Merge work in mybranch
! [mybranch] Some work.
--
- [master] Merge work in mybranch
*+ [mybranch] Some work.
-* [master^] Some fun.</tt></pre>
+* [master^] Some fun.</code></pre>
</div></div>
<div class="paragraph"><p>The first two lines indicate that it is showing the two branches
with the titles of their top-of-the-tree commits, you are currently on
-<tt>master</tt> branch (notice the asterisk <tt>*</tt> character), and the first
+<code>master</code> branch (notice the asterisk <code>*</code> character), and the first
column for the later output lines is used to show commits contained in the
-<tt>master</tt> branch, and the second column for the <tt>mybranch</tt>
+<code>master</code> branch, and the second column for the <code>mybranch</code>
branch. Three commits are shown along with their titles.
-All of them have non blank characters in the first column (<tt>*</tt>
-shows an ordinary commit on the current branch, <tt>-</tt> is a merge commit), which
-means they are now part of the <tt>master</tt> branch. Only the "Some
-work" commit has the plus <tt>+</tt> character in the second column,
-because <tt>mybranch</tt> has not been merged to incorporate these
+All of them have non blank characters in the first column (<code>*</code>
+shows an ordinary commit on the current branch, <code>-</code> is a merge commit), which
+means they are now part of the <code>master</code> branch. Only the "Some
+work" commit has the plus <code>+</code> character in the second column,
+because <code>mybranch</code> has not been merged to incorporate these
commits from the master branch. The string inside brackets
before the commit log message is a short name you can use to
name the commit. In the above example, <em>master</em> and <em>mybranch</em>
@@ -1520,40 +1703,42 @@ merge commit visible in this case.</td>
</tr></table>
</div>
<div class="paragraph"><p>Now, let&#8217;s pretend you are the one who did all the work in
-<tt>mybranch</tt>, and the fruit of your hard work has finally been merged
-to the <tt>master</tt> branch. Let&#8217;s go back to <tt>mybranch</tt>, and run
+<code>mybranch</code>, and the fruit of your hard work has finally been merged
+to the <code>master</code> branch. Let&#8217;s go back to <code>mybranch</code>, and run
<em>git merge</em> to get the "upstream changes" back to your branch.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout mybranch
-$ git merge -m "Merge upstream changes." master</tt></pre>
+<pre><code>$ git checkout mybranch
+$ git merge -m "Merge upstream changes." master</code></pre>
</div></div>
<div class="paragraph"><p>This outputs something like this (the actual commit object names
would be different)</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>Updating from ae3a2da... to a80b4aa....
+<pre><code>Updating from ae3a2da... to a80b4aa....
Fast-forward (no commit created; -m option ignored)
example | 1 +
hello | 1 +
- 2 files changed, 2 insertions(+)</tt></pre>
+ 2 files changed, 2 insertions(+)</code></pre>
</div></div>
<div class="paragraph"><p>Because your branch did not contain anything more than what had
-already been merged into the <tt>master</tt> branch, the merge operation did
+already been merged into the <code>master</code> branch, the merge operation did
not actually do a merge. Instead, it just updated the top of
-the tree of your branch to that of the <tt>master</tt> branch. This is
+the tree of your branch to that of the <code>master</code> branch. This is
often called <em>fast-forward</em> merge.</p></div>
-<div class="paragraph"><p>You can run <tt>gitk --all</tt> again to see how the commit ancestry
+<div class="paragraph"><p>You can run <code>gitk --all</code> again to see how the commit ancestry
looks like, or run <em>show-branch</em>, which tells you this.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git show-branch master mybranch
+<pre><code>$ git show-branch master mybranch
! [master] Merge work in mybranch
* [mybranch] Merge work in mybranch
--
--- [master] Merge work in mybranch</tt></pre>
+-- [master] Merge work in mybranch</code></pre>
</div></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_merging_external_work">Merging external work</h2>
<div class="sectionbody">
<div class="paragraph"><p>It&#8217;s usually much more common that you merge with somebody else than
@@ -1566,7 +1751,7 @@ followed by a <em>git merge</em>.</p></div>
<em>git fetch</em>:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git fetch &lt;remote-repository&gt;</tt></pre>
+<pre><code>$ git fetch &lt;remote-repository&gt;</code></pre>
</div></div>
<div class="paragraph"><p>One of the following transports can be used to name the
repository to download from:</p></div>
@@ -1576,15 +1761,15 @@ Rsync
</dt>
<dd>
<p>
- <tt>rsync://remote.machine/path/to/repo.git/</tt>
+ <code>rsync://remote.machine/path/to/repo.git/</code>
</p>
<div class="paragraph"><p>Rsync transport is usable for both uploading and downloading,
but is completely unaware of what git does, and can produce
unexpected results when you download from the public repository
-while the repository owner is uploading into it via <tt>rsync</tt>
+while the repository owner is uploading into it via <code>rsync</code>
transport. Most notably, it could update the files under
-<tt>refs/</tt> which holds the object name of the topmost commits
-before uploading the files in <tt>objects/</tt>&#8201;&#8212;&#8201;the downloader would
+<code>refs/</code> which holds the object name of the topmost commits
+before uploading the files in <code>objects/</code>&#8201;&#8212;&#8201;the downloader would
obtain head commit object name while that object itself is still
not available in the repository. For this reason, it is
considered deprecated.</p></div>
@@ -1594,11 +1779,11 @@ SSH
</dt>
<dd>
<p>
- <tt>remote.machine:/path/to/repo.git/</tt> or
+ <code>remote.machine:/path/to/repo.git/</code> or
</p>
-<div class="paragraph"><p><tt>ssh://remote.machine/path/to/repo.git/</tt></p></div>
+<div class="paragraph"><p><code>ssh://remote.machine/path/to/repo.git/</code></p></div>
<div class="paragraph"><p>This transport can be used for both uploading and downloading,
-and requires you to have a log-in privilege over <tt>ssh</tt> to the
+and requires you to have a log-in privilege over <code>ssh</code> to the
remote machine. It finds out the set of objects the other side
lacks by exchanging the head commits both ends have and
transfers (close to) minimum set of objects. It is by far the
@@ -1609,7 +1794,7 @@ Local directory
</dt>
<dd>
<p>
- <tt>/path/to/repo.git/</tt>
+ <code>/path/to/repo.git/</code>
</p>
<div class="paragraph"><p>This transport is the same as SSH transport but uses <em>sh</em> to run
both ends on the local machine instead of running other end on
@@ -1620,7 +1805,7 @@ git Native
</dt>
<dd>
<p>
- <tt>git://remote.machine/path/to/repo.git/</tt>
+ <code>git://remote.machine/path/to/repo.git/</code>
</p>
<div class="paragraph"><p>This transport was designed for anonymous downloading. Like SSH
transport, it finds out the set of objects the downstream side
@@ -1631,13 +1816,13 @@ HTTP(S)
</dt>
<dd>
<p>
- <tt>http://remote.machine/path/to/repo.git/</tt>
+ <code>http://remote.machine/path/to/repo.git/</code>
</p>
<div class="paragraph"><p>Downloader from http and https URL
first obtains the topmost commit object name from the remote site
-by looking at the specified refname under <tt>repo.git/refs/</tt> directory,
+by looking at the specified refname under <code>repo.git/refs/</code> directory,
and then tries to obtain the
-commit object by downloading from <tt>repo.git/objects/xx/xxx...</tt>
+commit object by downloading from <code>repo.git/objects/xx/xxx...</code>
using the object name of that commit object. Then it reads the
commit object to find out its parent commits and the associate
tree object; it repeats this process until it gets all the
@@ -1651,14 +1836,14 @@ you must prepare your repository with <em>git update-server-info</em>
to help dumb transport downloaders.</p></div>
</dd>
</dl></div>
-<div class="paragraph"><p>Once you fetch from the remote repository, you <tt>merge</tt> that
+<div class="paragraph"><p>Once you fetch from the remote repository, you <code>merge</code> that
with your current branch.</p></div>
-<div class="paragraph"><p>However&#8201;&#8212;&#8201;it&#8217;s such a common thing to <tt>fetch</tt> and then
-immediately <tt>merge</tt>, that it&#8217;s called <tt>git pull</tt>, and you can
+<div class="paragraph"><p>However&#8201;&#8212;&#8201;it&#8217;s such a common thing to <code>fetch</code> and then
+immediately <code>merge</code>, that it&#8217;s called <code>git pull</code>, and you can
simply do</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git pull &lt;remote-repository&gt;</tt></pre>
+<pre><code>$ git pull &lt;remote-repository&gt;</code></pre>
</div></div>
<div class="paragraph"><p>and optionally give a branch-name for the remote end as a second
argument.</p></div>
@@ -1671,7 +1856,7 @@ argument.</p></div>
keeping as many local repositories as you would like to have
branches, and merging between them with <em>git pull</em>, just like
you merge between branches. The advantage of this approach is
-that it lets you keep a set of files for each <tt>branch</tt> checked
+that it lets you keep a set of files for each <code>branch</code> checked
out and you may find it easier to switch back and forth if you
juggle multiple lines of development simultaneously. Of
course, you will pay the price of more disk usage to hold
@@ -1684,19 +1869,19 @@ the remote repository URL in the local repository&#8217;s config file
like this:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git config remote.linus.url http://www.kernel.org/pub/scm/git/git.git/</tt></pre>
+<pre><code>$ git config remote.linus.url http://www.kernel.org/pub/scm/git/git.git/</code></pre>
</div></div>
<div class="paragraph"><p>and use the "linus" keyword with <em>git pull</em> instead of the full URL.</p></div>
<div class="paragraph"><p>Examples.</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
-<tt>git pull linus</tt>
+<code>git pull linus</code>
</p>
</li>
<li>
<p>
-<tt>git pull linus tag v0.99.1</tt>
+<code>git pull linus tag v0.99.1</code>
</p>
</li>
</ol></div>
@@ -1704,16 +1889,18 @@ like this:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
-<tt>git pull http://www.kernel.org/pub/scm/git/git.git/ HEAD</tt>
+<code>git pull http://www.kernel.org/pub/scm/git/git.git/ HEAD</code>
</p>
</li>
<li>
<p>
-<tt>git pull http://www.kernel.org/pub/scm/git/git.git/ tag v0.99.1</tt>
+<code>git pull http://www.kernel.org/pub/scm/git/git.git/ tag v0.99.1</code>
</p>
</li>
</ol></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_how_does_the_merge_work">How does the merge work?</h2>
<div class="sectionbody">
<div class="paragraph"><p>We said this tutorial shows what plumbing does to help you cope
@@ -1726,42 +1913,42 @@ back to the earlier repository with "hello" and "example" file,
and bring ourselves back to the pre-merge state:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git show-branch --more=2 master mybranch
+<pre><code>$ git show-branch --more=2 master mybranch
! [master] Merge work in mybranch
* [mybranch] Merge work in mybranch
--
-- [master] Merge work in mybranch
+* [master^2] Some work.
-+* [master^] Some fun.</tt></pre>
++* [master^] Some fun.</code></pre>
</div></div>
-<div class="paragraph"><p>Remember, before running <em>git merge</em>, our <tt>master</tt> head was at
-"Some fun." commit, while our <tt>mybranch</tt> head was at "Some
+<div class="paragraph"><p>Remember, before running <em>git merge</em>, our <code>master</code> head was at
+"Some fun." commit, while our <code>mybranch</code> head was at "Some
work." commit.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git checkout mybranch
+<pre><code>$ git checkout mybranch
$ git reset --hard master^2
$ git checkout master
-$ git reset --hard master^</tt></pre>
+$ git reset --hard master^</code></pre>
</div></div>
<div class="paragraph"><p>After rewinding, the commit structure should look like this:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git show-branch
+<pre><code>$ git show-branch
* [master] Some fun.
! [mybranch] Some work.
--
* [master] Some fun.
+ [mybranch] Some work.
-*+ [master^] Initial commit</tt></pre>
+*+ [master^] Initial commit</code></pre>
</div></div>
<div class="paragraph"><p>Now we are ready to experiment with the merge by hand.</p></div>
-<div class="paragraph"><p><tt>git merge</tt> command, when merging two branches, uses 3-way merge
+<div class="paragraph"><p><code>git merge</code> command, when merging two branches, uses 3-way merge
algorithm. First, it finds the common ancestor between them.
The command it uses is <em>git merge-base</em>:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ mb=$(git merge-base HEAD mybranch)</tt></pre>
+<pre><code>$ mb=$(git merge-base HEAD mybranch)</code></pre>
</div></div>
<div class="paragraph"><p>The command writes the commit object name of the common ancestor
to the standard output, so we captured its output to a variable,
@@ -1770,14 +1957,14 @@ ancestor commit is the "Initial commit" commit in this case. You can
tell it by:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git name-rev --name-only --tags $mb
-my-first-tag</tt></pre>
+<pre><code>$ git name-rev --name-only --tags $mb
+my-first-tag</code></pre>
</div></div>
<div class="paragraph"><p>After finding out a common ancestor commit, the second step is
this:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git read-tree -m -u $mb HEAD mybranch</tt></pre>
+<pre><code>$ git read-tree -m -u $mb HEAD mybranch</code></pre>
</div></div>
<div class="paragraph"><p>This is the same <em>git read-tree</em> command we have already seen,
but it takes three trees, unlike previous examples. This reads
@@ -1794,11 +1981,11 @@ trees are left in non-zero stages. At this point, you can
inspect the index file with this command:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git ls-files --stage
+<pre><code>$ git ls-files --stage
100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
-100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</tt></pre>
+100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</code></pre>
</div></div>
<div class="paragraph"><p>In our example of only two files, we did not have unchanged
files so only <em>example</em> resulted in collapsing. But in real-life
@@ -1806,13 +1993,13 @@ large projects, when only a small number of files change in one commit,
this <em>collapsing</em> tends to trivially merge most of the paths
fairly quickly, leaving only a handful of real changes in non-zero
stages.</p></div>
-<div class="paragraph"><p>To look at only non-zero stages, use <tt>--unmerged</tt> flag:</p></div>
+<div class="paragraph"><p>To look at only non-zero stages, use <code>--unmerged</code> flag:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git ls-files --unmerged
+<pre><code>$ git ls-files --unmerged
100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
-100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</tt></pre>
+100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</code></pre>
</div></div>
<div class="paragraph"><p>The next step of merging is to merge these three versions of the
file, using 3-way merge. This is done by giving
@@ -1820,10 +2007,10 @@ file, using 3-way merge. This is done by giving
<em>git merge-index</em> command:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git merge-index git-merge-one-file hello
+<pre><code>$ git merge-index git-merge-one-file hello
Auto-merging hello
ERROR: Merge conflict in hello
-fatal: merge program failed</tt></pre>
+fatal: merge program failed</code></pre>
</div></div>
<div class="paragraph"><p><em>git merge-one-file</em> script is called with parameters to
describe those three versions, and is responsible to leave the
@@ -1832,29 +2019,31 @@ It is a fairly straightforward shell script, and
eventually calls <em>merge</em> program from RCS suite to perform a
file-level 3-way merge. In this case, <em>merge</em> detects
conflicts, and the merge result with conflict marks is left in
-the working tree.. This can be seen if you run <tt>ls-files
---stage</tt> again at this point:</p></div>
+the working tree.. This can be seen if you run <code>ls-files
+--stage</code> again at this point:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git ls-files --stage
+<pre><code>$ git ls-files --stage
100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
-100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</tt></pre>
+100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</code></pre>
</div></div>
<div class="paragraph"><p>This is the state of the index file and the working file after
<em>git merge</em> returns control back to you, leaving the conflicting
-merge for you to resolve. Notice that the path <tt>hello</tt> is still
+merge for you to resolve. Notice that the path <code>hello</code> is still
unmerged, and what you see with <em>git diff</em> at this point is
differences since stage 2 (i.e. your version).</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_publishing_your_work">Publishing your work</h2>
<div class="sectionbody">
<div class="paragraph"><p>So, we can use somebody else&#8217;s work from a remote repository, but
how can <strong>you</strong> prepare a repository to let other people pull from
it?</p></div>
<div class="paragraph"><p>You do your real work in your working tree that has your
-primary repository hanging under it as its <tt>.git</tt> subdirectory.
+primary repository hanging under it as its <code>.git</code> subdirectory.
You <strong>could</strong> make that repository accessible remotely and ask
people to pull from it, but in practice that is not the way
things are usually done. A recommended way is to have a public
@@ -1868,7 +2057,7 @@ update the public repository from it. This is often called
<div class="title">Note</div>
</td>
<td class="content">This public repository could further be mirrored, and that is
-how git repositories at <tt>kernel.org</tt> are managed.</td>
+how git repositories at <code>kernel.org</code> are managed.</td>
</tr></table>
</div>
<div class="paragraph"><p>Publishing the changes from your local (private) repository to
@@ -1891,26 +2080,26 @@ on the remote machine. The communication between the two over
the network internally uses an SSH connection.</td>
</tr></table>
</div>
-<div class="paragraph"><p>Your private repository&#8217;s git directory is usually <tt>.git</tt>, but
+<div class="paragraph"><p>Your private repository&#8217;s git directory is usually <code>.git</code>, but
your public repository is often named after the project name,
-i.e. <tt>&lt;project&gt;.git</tt>. Let&#8217;s create such a public repository for
-project <tt>my-git</tt>. After logging into the remote machine, create
+i.e. <code>&lt;project&gt;.git</code>. Let&#8217;s create such a public repository for
+project <code>my-git</code>. After logging into the remote machine, create
an empty directory:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ mkdir my-git.git</tt></pre>
+<pre><code>$ mkdir my-git.git</code></pre>
</div></div>
<div class="paragraph"><p>Then, make that directory into a git repository by running
<em>git init</em>, but this time, since its name is not the usual
-<tt>.git</tt>, we do things slightly differently:</p></div>
+<code>.git</code>, we do things slightly differently:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ GIT_DIR=my-git.git git init</tt></pre>
+<pre><code>$ GIT_DIR=my-git.git git init</code></pre>
</div></div>
<div class="paragraph"><p>Make sure this directory is available for others you want your
changes to be pulled via the transport of your choice. Also
you need to make sure that you have the <em>git-receive-pack</em>
-program on the <tt>$PATH</tt>.</p></div>
+program on the <code>$PATH</code>.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
@@ -1918,9 +2107,9 @@ program on the <tt>$PATH</tt>.</p></div>
</td>
<td class="content">Many installations of sshd do not invoke your shell as the login
shell when you directly run programs; what this means is that if
-your login shell is <em>bash</em>, only <tt>.bashrc</tt> is read and not
-<tt>.bash_profile</tt>. As a workaround, make sure <tt>.bashrc</tt> sets up
-<tt>$PATH</tt> so that you can run <em>git-receive-pack</em> program.</td>
+your login shell is <em>bash</em>, only <code>.bashrc</code> is read and not
+<code>.bash_profile</code>. As a workaround, make sure <code>.bashrc</code> sets up
+<code>$PATH</code> so that you can run <em>git-receive-pack</em> program.</td>
</tr></table>
</div>
<div class="admonitionblock">
@@ -1929,10 +2118,10 @@ your login shell is <em>bash</em>, only <tt>.bashrc</tt> is read and not
<div class="title">Note</div>
</td>
<td class="content">If you plan to publish this repository to be accessed over http,
-you should do <tt>mv my-git.git/hooks/post-update.sample
-my-git.git/hooks/post-update</tt> at this point.
+you should do <code>mv my-git.git/hooks/post-update.sample
+my-git.git/hooks/post-update</code> at this point.
This makes sure that every time you push into this
-repository, <tt>git update-server-info</tt> is run.</td>
+repository, <code>git update-server-info</code> is run.</td>
</tr></table>
</div>
<div class="paragraph"><p>Your "public repository" is now ready to accept your changes.
@@ -1940,22 +2129,24 @@ Come back to the machine you have your private repository. From
there, run this command:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git push &lt;public-host&gt;:/path/to/my-git.git master</tt></pre>
+<pre><code>$ git push &lt;public-host&gt;:/path/to/my-git.git master</code></pre>
</div></div>
<div class="paragraph"><p>This synchronizes your public repository to match the named
-branch head (i.e. <tt>master</tt> in this case) and objects reachable
+branch head (i.e. <code>master</code> in this case) and objects reachable
from them in your current repository.</p></div>
<div class="paragraph"><p>As a real example, this is how I update my public git
repository. Kernel.org mirror network takes care of the
propagation to other publicly visible machines:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git push master.kernel.org:/pub/scm/git/git.git/</tt></pre>
+<pre><code>$ git push master.kernel.org:/pub/scm/git/git.git/</code></pre>
</div></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_packing_your_repository">Packing your repository</h2>
<div class="sectionbody">
-<div class="paragraph"><p>Earlier, we saw that one file under <tt>.git/objects/??/</tt> directory
+<div class="paragraph"><p>Earlier, we saw that one file under <code>.git/objects/??/</code> directory
is stored for each git object you create. This representation
is efficient to create atomically and safely, but
not so convenient to transport over the network. Since git objects are
@@ -1963,20 +2154,20 @@ immutable once they are created, there is a way to optimize the
storage by "packing them together". The command</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git repack</tt></pre>
+<pre><code>$ git repack</code></pre>
</div></div>
<div class="paragraph"><p>will do it for you. If you followed the tutorial examples, you
-would have accumulated about 17 objects in <tt>.git/objects/??/</tt>
+would have accumulated about 17 objects in <code>.git/objects/??/</code>
directories by now. <em>git repack</em> tells you how many objects it
-packed, and stores the packed file in <tt>.git/objects/pack</tt>
+packed, and stores the packed file in <code>.git/objects/pack</code>
directory.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
-<td class="content">You will see two files, <tt>pack-*.pack</tt> and <tt>pack-*.idx</tt>,
-in <tt>.git/objects/pack</tt> directory. They are closely related to
+<td class="content">You will see two files, <code>pack-*.pack</code> and <code>pack-*.idx</code>,
+in <code>.git/objects/pack</code> directory. They are closely related to
each other, and if you ever copy them by hand to a different
repository for whatever reason, you should make sure you copy
them together. The former holds all the data from the objects
@@ -1991,40 +2182,42 @@ Our programs are always perfect ;-).</p></div>
unpacked objects that are contained in the pack file anymore.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git prune-packed</tt></pre>
+<pre><code>$ git prune-packed</code></pre>
</div></div>
<div class="paragraph"><p>would remove them for you.</p></div>
-<div class="paragraph"><p>You can try running <tt>find .git/objects -type f</tt> before and after
-you run <tt>git prune-packed</tt> if you are curious. Also <tt>git
-count-objects</tt> would tell you how many unpacked objects are in
+<div class="paragraph"><p>You can try running <code>find .git/objects -type f</code> before and after
+you run <code>git prune-packed</code> if you are curious. Also <code>git
+count-objects</code> would tell you how many unpacked objects are in
your repository and how much space they are consuming.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
-<td class="content"><tt>git pull</tt> is slightly cumbersome for HTTP transport, as a
+<td class="content"><code>git pull</code> is slightly cumbersome for HTTP transport, as a
packed repository may contain relatively few objects in a
relatively large pack. If you expect many HTTP pulls from your
public repository you might want to repack &amp; prune often, or
never.</td>
</tr></table>
</div>
-<div class="paragraph"><p>If you run <tt>git repack</tt> again at this point, it will say
+<div class="paragraph"><p>If you run <code>git repack</code> again at this point, it will say
"Nothing new to pack.". Once you continue your development and
-accumulate the changes, running <tt>git repack</tt> again will create a
+accumulate the changes, running <code>git repack</code> again will create a
new pack, that contains objects created since you packed your
repository the last time. We recommend that you pack your project
soon after the initial import (unless you are starting your
-project from scratch), and then run <tt>git repack</tt> every once in a
+project from scratch), and then run <code>git repack</code> every once in a
while, depending on how active your project is.</p></div>
-<div class="paragraph"><p>When a repository is synchronized via <tt>git push</tt> and <tt>git pull</tt>
+<div class="paragraph"><p>When a repository is synchronized via <code>git push</code> and <code>git pull</code>
objects packed in the source repository are usually stored
unpacked in the destination, unless rsync transport is used.
While this allows you to use different packing strategies on
both ends, it also means you may need to repack both
repositories every once in a while.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_working_with_others">Working with Others</h2>
<div class="sectionbody">
<div class="paragraph"><p>Although git is a truly distributed system, it is often
@@ -2050,11 +2243,11 @@ Prepare a public repository accessible to others.
</p>
<div class="paragraph"><p>If other people are pulling from your repository over dumb
transport protocols (HTTP), you need to keep this repository
-<em>dumb transport friendly</em>. After <tt>git init</tt>,
-<tt>$GIT_DIR/hooks/post-update.sample</tt> copied from the standard templates
+<em>dumb transport friendly</em>. After <code>git init</code>,
+<code>$GIT_DIR/hooks/post-update.sample</code> copied from the standard templates
would contain a call to <em>git update-server-info</em>
but you need to manually enable the hook with
-<tt>mv post-update.sample post-update</tt>. This makes sure
+<code>mv post-update.sample post-update</code>. This makes sure
<em>git update-server-info</em> keeps the necessary files up-to-date.</p></div>
</li>
<li>
@@ -2116,7 +2309,7 @@ Prepare a public repository accessible to others, just like
Copy over the packed files from "project lead" public
repository to your public repository, unless the "project
lead" repository lives on the same machine as yours. In the
- latter case, you can use <tt>objects/info/alternates</tt> file to
+ latter case, you can use <code>objects/info/alternates</code> file to
point at the repository you are borrowing from.
</p>
</li>
@@ -2173,28 +2366,30 @@ Do your work in your repository on <em>master</em> branch.
</li>
<li>
<p>
-Run <tt>git fetch origin</tt> from the public repository of your
+Run <code>git fetch origin</code> from the public repository of your
upstream every once in a while. This does only the first
- half of <tt>git pull</tt> but does not merge. The head of the
- public repository is stored in <tt>.git/refs/remotes/origin/master</tt>.
+ half of <code>git pull</code> but does not merge. The head of the
+ public repository is stored in <code>.git/refs/remotes/origin/master</code>.
</p>
</li>
<li>
<p>
-Use <tt>git cherry origin</tt> to see which ones of your patches
- were accepted, and/or use <tt>git rebase origin</tt> to port your
+Use <code>git cherry origin</code> to see which ones of your patches
+ were accepted, and/or use <code>git rebase origin</code> to port your
unmerged changes forward to the updated upstream.
</p>
</li>
<li>
<p>
-Use <tt>git format-patch origin</tt> to prepare patches for e-mail
+Use <code>git format-patch origin</code> to prepare patches for e-mail
submission to your upstream and send it out. Go back to
step 2. and continue.
</p>
</li>
</ol></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_working_with_others_shared_repository_style">Working with Others, Shared Repository Style</h2>
<div class="sectionbody">
<div class="paragraph"><p>If you are coming from CVS background, the style of cooperation
@@ -2203,6 +2398,8 @@ have to worry. git supports "shared public repository" style of
cooperation you are probably more familiar with as well.</p></div>
<div class="paragraph"><p>See <a href="gitcvs-migration.html">gitcvs-migration(7)</a> for the details.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_bundling_your_work_together">Bundling your work together</h2>
<div class="sectionbody">
<div class="paragraph"><p>It is likely that you will be working on more than one thing at
@@ -2216,7 +2413,7 @@ branch, and two independent fixes in the "commit-fix" and
"diff-fix" branches:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git show-branch
+<pre><code>$ git show-branch
! [commit-fix] Fix commit message normalization.
! [diff-fix] Fix rename detection.
* [master] Release candidate #1
@@ -2225,20 +2422,20 @@ branch, and two independent fixes in the "commit-fix" and
+ [diff-fix~1] Better common substring algorithm.
+ [commit-fix] Fix commit message normalization.
* [master] Release candidate #1
-++* [diff-fix~2] Pretty-print messages.</tt></pre>
+++* [diff-fix~2] Pretty-print messages.</code></pre>
</div></div>
<div class="paragraph"><p>Both fixes are tested well, and at this point, you want to merge
in both of them. You could merge in <em>diff-fix</em> first and then
<em>commit-fix</em> next, like this:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git merge -m "Merge fix in diff-fix" diff-fix
-$ git merge -m "Merge fix in commit-fix" commit-fix</tt></pre>
+<pre><code>$ git merge -m "Merge fix in diff-fix" diff-fix
+$ git merge -m "Merge fix in commit-fix" commit-fix</code></pre>
</div></div>
<div class="paragraph"><p>Which would result in:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git show-branch
+<pre><code>$ git show-branch
! [commit-fix] Fix commit message normalization.
! [diff-fix] Fix rename detection.
* [master] Merge fix in commit-fix
@@ -2249,7 +2446,7 @@ $ git merge -m "Merge fix in commit-fix" commit-fix</tt></pre>
+* [diff-fix] Fix rename detection.
+* [diff-fix~1] Better common substring algorithm.
* [master~2] Release candidate #1
-++* [master~3] Pretty-print messages.</tt></pre>
+++* [master~3] Pretty-print messages.</code></pre>
</div></div>
<div class="paragraph"><p>However, there is no particular reason to merge in one branch
first and the other next, when what you have are a set of truly
@@ -2260,15 +2457,15 @@ we just did and start over. We would want to get the master
branch before these two merges by resetting it to <em>master~2</em>:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git reset --hard master~2</tt></pre>
+<pre><code>$ git reset --hard master~2</code></pre>
</div></div>
-<div class="paragraph"><p>You can make sure <tt>git show-branch</tt> matches the state before
+<div class="paragraph"><p>You can make sure <code>git show-branch</code> matches the state before
those two <em>git merge</em> you just did. Then, instead of running
two <em>git merge</em> commands in a row, you would merge these two
branch heads (this is known as <em>making an Octopus</em>):</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>$ git merge commit-fix diff-fix
+<pre><code>$ git merge commit-fix diff-fix
$ git show-branch
! [commit-fix] Fix commit message normalization.
! [diff-fix] Fix rename detection.
@@ -2279,7 +2476,7 @@ $ git show-branch
+* [diff-fix] Fix rename detection.
+* [diff-fix~1] Better common substring algorithm.
* [master~1] Release candidate #1
-++* [master~2] Pretty-print messages.</tt></pre>
+++* [master~2] Pretty-print messages.</code></pre>
</div></div>
<div class="paragraph"><p>Note that you should not do Octopus because you can. An octopus
is a valid thing to do and often makes it easier to view the
@@ -2293,6 +2490,8 @@ and the reason why you preferred changes made in one side over
the other. Otherwise it would make the project history harder
to follow, not easier.</p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_see_also">SEE ALSO</h2>
<div class="sectionbody">
<div class="paragraph"><p><a href="gittutorial.html">gittutorial(7)</a>,
@@ -2302,11 +2501,14 @@ to follow, not easier.</p></div>
<a href="everyday.html">Everyday git</a>,
<a href="user-manual.html">The Git User&#8217;s Manual</a></p></div>
</div>
+</div>
+<div class="sect1">
<h2 id="_git">GIT</h2>
<div class="sectionbody">
<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite.</p></div>
</div>
</div>
+</div>
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">