-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Git User's Manual</title><link rel="stylesheet" href="docbook-xsl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="id232635"></a>Git User's Manual</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="preface"><a href="#id264704">Preface</a></span></dt><dt><span class="chapter"><a href="#id233155">1. Git Quick Start</a></span></dt><dd><dl><dt><span class="section"><a href="#id233166">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233198">Managing branches</a></span></dt><dt><span class="section"><a href="#id232445">Exploring history</a></span></dt><dt><span class="section"><a href="#id232489">Making changes</a></span></dt><dt><span class="section"><a href="#id233361">Merging</a></span></dt><dt><span class="section"><a href="#id233378">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233463">Repository maintenance</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id232662">2. Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#id232667">How to get a git repository</a></span></dt><dt><span class="section"><a href="#id232724">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#id273402">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#id273567">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#id273607">Understanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#id273635">Understanding history: What is a branch?</a></span></dt></dl></dd><dt><span class="section"><a href="#id273658">Manipulating branches</a></span></dt><dt><span class="section"><a href="#id273790">Examining branches from a remote repository</a></span></dt><dt><span class="section"><a href="#how-git-stores-references">Naming branches, tags, and other references</a></span></dt><dt><span class="section"><a href="#Updating-a-repository-with-git-fetch">Updating a repository with git fetch</a></span></dt><dt><span class="section"><a href="#id274036">Fetching branches from other repositories</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id274110">3. Exploring git history</a></span></dt><dd><dl><dt><span class="section"><a href="#id274132">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274252">Naming commits</a></span></dt><dt><span class="section"><a href="#id274400">Creating tags</a></span></dt><dt><span class="section"><a href="#id274435">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274509">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274552">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274578">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274583">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274636">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id274800">4. Developing with git</a></span></dt><dd><dl><dt><span class="section"><a href="#id274805">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274837">Creating a new repository</a></span></dt><dt><span class="section"><a href="#how-to-make-a-commit">how to make a commit</a></span></dt><dt><span class="section"><a href="#id275065">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275081">how to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dd><dl><dt><span class="section"><a href="#id275222">Getting conflict-resolution help during a merge</a></span></dt></dl></dd><dt><span class="section"><a href="#undoing-a-merge">undoing a merge</a></span></dt><dt><span class="section"><a href="#id275431">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275460">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275513">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#fixing-a-mistake-by-editing-history">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275645">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275704">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275741">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275747">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275822">Recovering lost changes</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id275972">5. Sharing development with others</a></span></dt><dd><dl><dt><span class="section"><a href="#getting-updates-with-git-pull">Getting updates with git pull</a></span></dt><dt><span class="section"><a href="#id276103">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276153">Importing patches to a project</a></span></dt><dt><span class="section"><a href="#setting-up-a-public-repository">Setting up a public repository</a></span></dt><dt><span class="section"><a href="#exporting-via-http">Exporting a git repository via http</a></span></dt><dt><span class="section"><a href="#exporting-via-git">Exporting a git repository via the git protocol</a></span></dt><dt><span class="section"><a href="#pushing-changes-to-a-public-repository">Pushing changes to a public repository</a></span></dt><dt><span class="section"><a href="#id276564">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276584">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276596">Examples</a></span></dt></dl></dd><dt><span class="chapter"><a href="#cleaning-up-history">6. Rewriting history and maintaining patch series</a></span></dt><dd><dl><dt><span class="section"><a href="#id276628">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276703">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276834">Modifying a single commit</a></span></dt><dt><span class="section"><a href="#id276924">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276984">Other tools</a></span></dt><dt><span class="section"><a href="#id276997">Problems with rewriting history</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id277069">7. Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#id277075">Fetching individual branches</a></span></dt><dt><span class="section"><a href="#fast-forwards">Understanding git history: fast-forwards</a></span></dt><dt><span class="section"><a href="#id277195">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277222">Configuring remote branches</a></span></dt></dl></dd><dt><span class="chapter"><a href="#git-internals">8. Git internals</a></span></dt><dd><dl><dt><span class="section"><a href="#id277360">The Object Database</a></span></dt><dt><span class="section"><a href="#id277475">Blob Object</a></span></dt><dt><span class="section"><a href="#id277519">Tree Object</a></span></dt><dt><span class="section"><a href="#id277596">Commit Object</a></span></dt><dt><span class="section"><a href="#id277643">Trust</a></span></dt><dt><span class="section"><a href="#id277694">Tag Object</a></span></dt><dt><span class="section"><a href="#id277740">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277815">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277834">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277923">index -> object database</a></span></dt><dt><span class="section"><a href="#id277952">object database -> index</a></span></dt><dt><span class="section"><a href="#id277982">index -> working directory</a></span></dt><dt><span class="section"><a href="#id278046">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278141">Examining the data</a></span></dt><dt><span class="section"><a href="#id278219">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278306">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278566">How git stores objects efficiently: pack files</a></span></dt><dt><span class="section"><a href="#dangling-objects">Dangling objects</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id278826">9. Glossary of git terms</a></span></dt><dt><span class="chapter"><a href="#id280073">10. Notes and todo list for this manual</a></span></dt></dl></div><div class="preface" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id264704"></a>Preface</h2></div></div></div><p>This manual is designed to be readable by someone with basic unix
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Git User's Manual</title><link rel="stylesheet" href="docbook-xsl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="id232635"></a>Git User's Manual</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="preface"><a href="#id264704">Preface</a></span></dt><dt><span class="chapter"><a href="#id233155">1. Git Quick Start</a></span></dt><dd><dl><dt><span class="section"><a href="#id233166">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233198">Managing branches</a></span></dt><dt><span class="section"><a href="#id232445">Exploring history</a></span></dt><dt><span class="section"><a href="#id232489">Making changes</a></span></dt><dt><span class="section"><a href="#id233361">Merging</a></span></dt><dt><span class="section"><a href="#id233378">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233463">Repository maintenance</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id232662">2. Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#id232667">How to get a git repository</a></span></dt><dt><span class="section"><a href="#id232724">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#id273402">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#id273567">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#id273607">Understanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#id273635">Understanding history: What is a branch?</a></span></dt></dl></dd><dt><span class="section"><a href="#id273658">Manipulating branches</a></span></dt><dt><span class="section"><a href="#id273790">Examining branches from a remote repository</a></span></dt><dt><span class="section"><a href="#how-git-stores-references">Naming branches, tags, and other references</a></span></dt><dt><span class="section"><a href="#Updating-a-repository-with-git-fetch">Updating a repository with git fetch</a></span></dt><dt><span class="section"><a href="#id274036">Fetching branches from other repositories</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id274110">3. Exploring git history</a></span></dt><dd><dl><dt><span class="section"><a href="#id274132">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274252">Naming commits</a></span></dt><dt><span class="section"><a href="#id274400">Creating tags</a></span></dt><dt><span class="section"><a href="#id274435">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274509">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274552">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274578">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274583">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274636">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id274800">4. Developing with git</a></span></dt><dd><dl><dt><span class="section"><a href="#id274805">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274837">Creating a new repository</a></span></dt><dt><span class="section"><a href="#how-to-make-a-commit">how to make a commit</a></span></dt><dt><span class="section"><a href="#id275065">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275081">how to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dd><dl><dt><span class="section"><a href="#id275217">Getting conflict-resolution help during a merge</a></span></dt></dl></dd><dt><span class="section"><a href="#undoing-a-merge">undoing a merge</a></span></dt><dt><span class="section"><a href="#id275426">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275455">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275508">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#fixing-a-mistake-by-editing-history">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275640">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275699">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275736">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275742">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275817">Recovering lost changes</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id275967">5. Sharing development with others</a></span></dt><dd><dl><dt><span class="section"><a href="#getting-updates-with-git-pull">Getting updates with git pull</a></span></dt><dt><span class="section"><a href="#id276098">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276148">Importing patches to a project</a></span></dt><dt><span class="section"><a href="#setting-up-a-public-repository">Setting up a public repository</a></span></dt><dt><span class="section"><a href="#exporting-via-http">Exporting a git repository via http</a></span></dt><dt><span class="section"><a href="#exporting-via-git">Exporting a git repository via the git protocol</a></span></dt><dt><span class="section"><a href="#pushing-changes-to-a-public-repository">Pushing changes to a public repository</a></span></dt><dt><span class="section"><a href="#id276559">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276578">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276591">Examples</a></span></dt></dl></dd><dt><span class="chapter"><a href="#cleaning-up-history">6. Rewriting history and maintaining patch series</a></span></dt><dd><dl><dt><span class="section"><a href="#id276623">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276698">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276828">Modifying a single commit</a></span></dt><dt><span class="section"><a href="#id276918">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276978">Other tools</a></span></dt><dt><span class="section"><a href="#id276991">Problems with rewriting history</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id277062">7. Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#id277068">Fetching individual branches</a></span></dt><dt><span class="section"><a href="#fast-forwards">Understanding git history: fast-forwards</a></span></dt><dt><span class="section"><a href="#id277188">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277215">Configuring remote branches</a></span></dt></dl></dd><dt><span class="chapter"><a href="#git-internals">8. Git internals</a></span></dt><dd><dl><dt><span class="section"><a href="#id277353">The Object Database</a></span></dt><dt><span class="section"><a href="#id277469">Blob Object</a></span></dt><dt><span class="section"><a href="#id277512">Tree Object</a></span></dt><dt><span class="section"><a href="#id232240">Commit Object</a></span></dt><dt><span class="section"><a href="#id277705">Trust</a></span></dt><dt><span class="section"><a href="#id277755">Tag Object</a></span></dt><dt><span class="section"><a href="#id277801">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277877">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277895">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277985">index -> object database</a></span></dt><dt><span class="section"><a href="#id278013">object database -> index</a></span></dt><dt><span class="section"><a href="#id278044">index -> working directory</a></span></dt><dt><span class="section"><a href="#id278108">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278202">Examining the data</a></span></dt><dt><span class="section"><a href="#id278280">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278368">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278628">How git stores objects efficiently: pack files</a></span></dt><dt><span class="section"><a href="#dangling-objects">Dangling objects</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id278888">9. Glossary of git terms</a></span></dt><dt><span class="chapter"><a href="#id280134">10. Notes and todo list for this manual</a></span></dt></dl></div><div class="preface" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id264704"></a>Preface</h2></div></div></div><p>This manual is designed to be readable by someone with basic unix
command-line skills, but no previous knowledge of git.</p><p>Chapter 1 gives a brief overview of git commands, without any
explanation; you may prefer to skip to chapter 2 on a first reading.</p><p>Chapters 2 and 3 explain how to fetch and study a project using
git—the tools you'd need to build and test a particular version of a
that Y is a descendent of X, or that there is a chain of parents
leading from commit Y to commit X.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id273607"></a>Understanding history: History diagrams</h3></div></div></div><p>We will sometimes represent git history using diagrams like the one
below. Commits are shown as "o", and the links between them with
-lines drawn with - / and \. Time goes left to right:</p><pre class="literallayout"> o--o--o <-- Branch A
- /
-o--o--o <-- master
- o--o--o <-- Branch B</pre><p>If we need to talk about a particular commit, the character "o" may
+lines drawn with - / and \. Time goes left to right:</p><pre class="literallayout"> o--o--o <-- Branch A
+ /
+ o--o--o <-- master
+ \
+ o--o--o <-- Branch B</pre><p>If we need to talk about a particular commit, the character "o" may
be replaced with another letter or number.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id273635"></a>Understanding history: What is a branch?</h3></div></div></div><p>Though we've been using the word "branch" to mean a kind of reference
to a particular commit, the word branch is also commonly used to
refer to the line of commits leading up to that point. In the
a new stanza:</p><div class="literallayout"><p>$ cat .git/config<br>
...<br>
[remote "linux-nfs"]<br>
- url = git://linux-nfs.org/~bfields/git.git<br>
- fetch = +refs/heads/*:refs/remotes/linux-nfs-read/*<br>
+ url = git://linux-nfs.org/pub/nfs-2.6.git<br>
+ fetch = +refs/heads/*:refs/remotes/linux-nfs/*<br>
...</p></div><p>This is what causes git to track the remote's branches; you may modify
or delete these configuration options by editing .git/config with a
text editor. (See the "CONFIGURATION FILE" section of
! [v1.5.0-rc2] GIT v1.5.0-rc2<br>
...</p></div><p>then search for a line that looks like</p><div class="literallayout"><p>+ ++ [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if<br>
available</p></div><p>Which shows that e05db0fd is reachable from itself, from v1.5.0-rc1, and
-from v1.5.0-rc2, but not from v1.5.0-rc0.</p></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id274800"></a>Chapter 4. Developing with git</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id274805">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274837">Creating a new repository</a></span></dt><dt><span class="section"><a href="#how-to-make-a-commit">how to make a commit</a></span></dt><dt><span class="section"><a href="#id275065">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275081">how to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dd><dl><dt><span class="section"><a href="#id275222">Getting conflict-resolution help during a merge</a></span></dt></dl></dd><dt><span class="section"><a href="#undoing-a-merge">undoing a merge</a></span></dt><dt><span class="section"><a href="#id275431">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275460">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275513">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#fixing-a-mistake-by-editing-history">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275645">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275704">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275741">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275747">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275822">Recovering lost changes</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id274805"></a>Telling git your name</h2></div></div></div><p>Before creating any commits, you should introduce yourself to git. The
+from v1.5.0-rc2, but not from v1.5.0-rc0.</p></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id274800"></a>Chapter 4. Developing with git</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id274805">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274837">Creating a new repository</a></span></dt><dt><span class="section"><a href="#how-to-make-a-commit">how to make a commit</a></span></dt><dt><span class="section"><a href="#id275065">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275081">how to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dd><dl><dt><span class="section"><a href="#id275217">Getting conflict-resolution help during a merge</a></span></dt></dl></dd><dt><span class="section"><a href="#undoing-a-merge">undoing a merge</a></span></dt><dt><span class="section"><a href="#id275426">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275455">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275508">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#fixing-a-mistake-by-editing-history">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275640">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275699">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275736">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275742">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275817">Recovering lost changes</a></span></dt></dl></dd></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id274805"></a>Telling git your name</h2></div></div></div><p>Before creating any commits, you should introduce yourself to git. The
easiest way to do so is:</p><div class="literallayout"><p>$ cat >~/.gitconfig <<\EOF<br>
[user]<br>
name = Your Name Comes Here<br>
<a href="git-merge.html" target="_top">git-merge(1)</a>:</p><div class="literallayout"><p>$ git merge branchname</p></div><p>merges the development in the branch "branchname" into the current
branch. If there are conflicts—for example, if the same file is
modified in two different ways in the remote branch and the local
-branch—then you are warned; the output may look something like this:</p><div class="literallayout"><p>$ git pull . next<br>
-Trying really trivial in-index merge...<br>
-fatal: Merge requires file-level merging<br>
-Nope.<br>
-Merging HEAD with 77976da35a11db4580b80ae27e8d65caf5208086<br>
-Merging:<br>
-15e2162 world<br>
-77976da goodbye<br>
-found 1 common ancestor(s):<br>
-d122ed4 initial<br>
-Auto-merging file.txt<br>
+branch—then you are warned; the output may look something like this:</p><div class="literallayout"><p>$ git merge next<br>
+ 100% (4/4) done<br>
+Auto-merged file.txt<br>
CONFLICT (content): Merge conflict in file.txt<br>
Automatic merge failed; fix conflicts and then commit the result.</p></div><p>Conflict markers are left in the problematic files, and after
you resolve the conflicts manually, you can update the index
some information about the merge. Normally you can just use this
default message unchanged, but you may add additional commentary of
your own if desired.</p><p>The above is all you need to know to resolve a simple merge. But git
-also provides more information to help resolve conflicts:</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275222"></a>Getting conflict-resolution help during a merge</h3></div></div></div><p>All of the changes that git was able to merge automatically are
+also provides more information to help resolve conflicts:</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275217"></a>Getting conflict-resolution help during a merge</h3></div></div></div><p>All of the changes that git was able to merge automatically are
already added to the index file, so <a href="git-diff.html" target="_top">git-diff(1)</a> shows only
the conflicts. It uses an unusual syntax:</p><div class="literallayout"><p>$ git diff<br>
diff --cc file.txt<br>
away, you can always return to the pre-merge state with</p><div class="literallayout"><p>$ git reset --hard HEAD</p></div><p>Or, if you've already commited the merge that you want to throw away,</p><div class="literallayout"><p>$ git reset --hard ORIG_HEAD</p></div><p>However, this last command can be dangerous in some cases—never
throw away a commit you have already committed if that commit may
itself have been merged into another branch, as doing so may confuse
-further merges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275431"></a>Fast-forward merges</h2></div></div></div><p>There is one special case not mentioned above, which is treated
+further merges.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275426"></a>Fast-forward merges</h2></div></div></div><p>There is one special case not mentioned above, which is treated
differently. Normally, a merge results in a merge commit, with two
parents, one pointing at each of the two lines of development that
were merged.</p><p>However, if one of the two lines of development is completely
already contained in the other—then git just performs a
<a href="#fast-forwards" title="Understanding git history: fast-forwards">fast forward</a>; the head of the current branch is
moved forward to point at the head of the merged-in branch, without
-any new commits being created.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275460"></a>Fixing mistakes</h2></div></div></div><p>If you've messed up the working tree, but haven't yet committed your
+any new commits being created.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275455"></a>Fixing mistakes</h2></div></div></div><p>If you've messed up the working tree, but haven't yet committed your
mistake, you can return the entire working tree to the last committed
state with</p><div class="literallayout"><p>$ git reset --hard HEAD</p></div><p>If you make a commit that you later wish you hadn't, there are two
fundamentally different ways to fix the problem:</p><div class="orderedlist"><ol type="1"><li>
git does not normally expect the "history" of a project to
change, and cannot correctly perform repeated merges from
a branch that has had its history changed.
-</li></ol></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275513"></a>Fixing a mistake with a new commit</h3></div></div></div><p>Creating a new commit that reverts an earlier change is very easy;
+</li></ol></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275508"></a>Fixing a mistake with a new commit</h3></div></div></div><p>Creating a new commit that reverts an earlier change is very easy;
just pass the <a href="git-revert.html" target="_top">git-revert(1)</a> command a reference to the bad
commit; for example, to revert the most recent commit:</p><div class="literallayout"><p>$ git revert HEAD</p></div><p>This will create a new commit which undoes the change in HEAD. You
will be given a chance to edit the commit message for the new commit.</p><p>You can also revert an earlier change, for example, the next-to-last:</p><div class="literallayout"><p>$ git revert HEAD^</p></div><p>In this case git will attempt to undo the old change while leaving
been merged into another branch; use <a href="git-revert.html" target="_top">git-revert(1)</a> instead in
that case.</p><p>It is also possible to edit commits further back in the history, but
this is an advanced topic to be left for
-<a href="#cleaning-up-history" title="Chapter 6. Rewriting history and maintaining patch series">another chapter</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275645"></a>Checking out an old version of a file</h3></div></div></div><p>In the process of undoing a previous bad change, you may find it
+<a href="#cleaning-up-history" title="Chapter 6. Rewriting history and maintaining patch series">another chapter</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275640"></a>Checking out an old version of a file</h3></div></div></div><p>In the process of undoing a previous bad change, you may find it
useful to check out an older version of a particular file using
<a href="git-checkout.html" target="_top">git-checkout(1)</a>. We've used git checkout before to switch
branches, but it has quite different behavior if it is given a path
name: the command</p><div class="literallayout"><p>$ git checkout HEAD^ path/to/file</p></div><p>replaces path/to/file by the contents it had in the commit HEAD^, and
also updates the index to match. It does not change branches.</p><p>If you just want to look at an old version of the file, without
modifying the working directory, you can do that with
-<a href="git-show.html" target="_top">git-show(1)</a>:</p><div class="literallayout"><p>$ git show HEAD^ path/to/file</p></div><p>which will display the given version of the file.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275704"></a>Ensuring good performance</h2></div></div></div><p>On large repositories, git depends on compression to keep the history
+<a href="git-show.html" target="_top">git-show(1)</a>:</p><div class="literallayout"><p>$ git show HEAD^:path/to/file</p></div><p>which will display the given version of the file.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275699"></a>Ensuring good performance</h2></div></div></div><p>On large repositories, git depends on compression to keep the history
information from taking up to much space on disk or in memory.</p><p>This compression is not performed automatically. Therefore you
should occasionally run <a href="git-gc.html" target="_top">git-gc(1)</a>:</p><div class="literallayout"><p>$ git gc</p></div><p>to recompress the archive. This can be very time-consuming, so
-you may prefer to run git-gc when you are not doing other work.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275741"></a>Ensuring reliability</h2></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275747"></a>Checking the repository for corruption</h3></div></div></div><p>The <a href="git-fsck.html" target="_top">git-fsck(1)</a> command runs a number of self-consistency checks
+you may prefer to run git-gc when you are not doing other work.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id275736"></a>Ensuring reliability</h2></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275742"></a>Checking the repository for corruption</h3></div></div></div><p>The <a href="git-fsck.html" target="_top">git-fsck(1)</a> command runs a number of self-consistency checks
on the repository, and reports on any problems. This may take some
time. The most common warning by far is about "dangling" objects:</p><div class="literallayout"><p>$ git fsck<br>
dangling commit 7281251ddd2a61e38657c827739c57015671a6b3<br>
you can remove them at any time with <a href="git-prune.html" target="_top">git-prune(1)</a> or the —prune
option to <a href="git-gc.html" target="_top">git-gc(1)</a>:</p><div class="literallayout"><p>$ git gc --prune</p></div><p>This may be time-consuming. Unlike most other git operations (including
git-gc when run without any options), it is not safe to prune while
-other git operations are in progress in the same repository.</p><p>For more about dangling objects, see <a href="#dangling-objects" title="Dangling objects">the section called “Dangling objects”</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275822"></a>Recovering lost changes</h3></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id275827"></a>Reflogs</h4></div></div></div><p>Say you modify a branch with <a href="git-reset.html" target="_top">git-reset(1)</a> —hard, and then
+other git operations are in progress in the same repository.</p><p>For more about dangling objects, see <a href="#dangling-objects" title="Dangling objects">the section called “Dangling objects”</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id275817"></a>Recovering lost changes</h3></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id275822"></a>Reflogs</h4></div></div></div><p>Say you modify a branch with <a href="git-reset.html" target="_top">git-reset(1)</a> —hard, and then
realize that the branch was the only reference you had to that point in
history.</p><p>Fortunately, git also keeps a log, called a "reflog", of all the
previous values of each branch. So in this case you can still find the
section of <a href="git-rev-parse.html" target="_top">git-rev-parse(1)</a> for details.</p><p>Note that the reflog history is very different from normal git history.
While normal history is shared by every repository that works on the
same project, the reflog history is not shared: it tells you only about
-how the branches in your local repository have changed over time.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id275906"></a>Examining dangling objects</h4></div></div></div><p>In some situations the reflog may not be able to save you. For
+how the branches in your local repository have changed over time.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id275900"></a>Examining dangling objects</h4></div></div></div><p>In some situations the reflog may not be able to save you. For
example, suppose you delete a branch, then realize you need the history
it contained. The reflog is also deleted; however, if you have not
yet pruned the repository, then you may still be able to find
(And notice that it might not be just one commit: we only report the
"tip of the line" as being dangling, but there might be a whole deep
and complex commit history that was dropped.)</p><p>If you decide you want the history back, you can always create a new
-reference pointing to it, for example, a new branch:</p><div class="literallayout"><p>$ git branch recovered-branch 7281251ddd</p></div></div></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id275972"></a>Chapter 5. Sharing development with others</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#getting-updates-with-git-pull">Getting updates with git pull</a></span></dt><dt><span class="section"><a href="#id276103">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276153">Importing patches to a project</a></span></dt><dt><span class="section"><a href="#setting-up-a-public-repository">Setting up a public repository</a></span></dt><dt><span class="section"><a href="#exporting-via-http">Exporting a git repository via http</a></span></dt><dt><span class="section"><a href="#exporting-via-git">Exporting a git repository via the git protocol</a></span></dt><dt><span class="section"><a href="#pushing-changes-to-a-public-repository">Pushing changes to a public repository</a></span></dt><dt><span class="section"><a href="#id276564">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276584">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276596">Examples</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="getting-updates-with-git-pull"></a>Getting updates with git pull</h2></div></div></div><p>After you clone a repository and make a few changes of your own, you
+reference pointing to it, for example, a new branch:</p><div class="literallayout"><p>$ git branch recovered-branch 7281251ddd</p></div></div></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id275967"></a>Chapter 5. Sharing development with others</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#getting-updates-with-git-pull">Getting updates with git pull</a></span></dt><dt><span class="section"><a href="#id276098">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276148">Importing patches to a project</a></span></dt><dt><span class="section"><a href="#setting-up-a-public-repository">Setting up a public repository</a></span></dt><dt><span class="section"><a href="#exporting-via-http">Exporting a git repository via http</a></span></dt><dt><span class="section"><a href="#exporting-via-git">Exporting a git repository via the git protocol</a></span></dt><dt><span class="section"><a href="#pushing-changes-to-a-public-repository">Pushing changes to a public repository</a></span></dt><dt><span class="section"><a href="#id276559">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276578">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276591">Examples</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="getting-updates-with-git-pull"></a>Getting updates with git pull</h2></div></div></div><p>After you clone a repository and make a few changes of your own, you
may wish to check the original repository for updates and merge them
into your own work.</p><p>We have already seen <a href="#Updating-a-repository-with-git-fetch" title="Updating a repository with git fetch">how to keep remote tracking branches up to date</a> with <a href="git-fetch.html" target="_top">git-fetch(1)</a>,
and how to merge two branches. So you can merge in changes from the
updated to point to the latest commit from the upstream branch.)</p><p>The git-pull command can also be given "." as the "remote" repository,
in which case it just merges in a branch from the current repository; so
the commands</p><div class="literallayout"><p>$ git pull . branch<br>
-$ git merge branch</p></div><p>are roughly equivalent. The former is actually very commonly used.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276103"></a>Submitting patches to a project</h2></div></div></div><p>If you just have a few changes, the simplest way to submit them may
+$ git merge branch</p></div><p>are roughly equivalent. The former is actually very commonly used.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276098"></a>Submitting patches to a project</h2></div></div></div><p>If you just have a few changes, the simplest way to submit them may
just be to send them as patches in email:</p><p>First, use <a href="git-format-patch.html" target="_top">git-format-patch(1)</a>; for example:</p><div class="literallayout"><p>$ git format-patch origin</p></div><p>will produce a numbered series of files in the current directory, one
for each patch in the current branch but not in origin/HEAD.</p><p>You can then import these into your mail client and send them by
hand. However, if you have a lot to send at once, you may prefer to
use the <a href="git-send-email.html" target="_top">git-send-email(1)</a> script to automate the process.
Consult the mailing list for your project first to determine how they
-prefer such patches be handled.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276153"></a>Importing patches to a project</h2></div></div></div><p>Git also provides a tool called <a href="git-am.html" target="_top">git-am(1)</a> (am stands for
+prefer such patches be handled.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276148"></a>Importing patches to a project</h2></div></div></div><p>Git also provides a tool called <a href="git-am.html" target="_top">git-am(1)</a> (am stands for
"apply mailbox"), for importing such an emailed series of patches.
Just save all of the patch-containing messages, in order, into a
single mailbox file, say "patches.mbox", then run</p><div class="literallayout"><p>$ git am -3 patches.mbox</p></div><p>Git will apply each patch in order; if any conflicts are found, it
url = ssh://yourserver.com/~you/proj.git<br>
EOF</p></div><p>you should be able to perform the above push with just</p><div class="literallayout"><p>$ git push public-repo master</p></div><p>See the explanations of the remote.<name>.url, branch.<name>.remote,
and remote.<name>.push options in <a href="git-config.html" target="_top">git-config(1)</a> for
-details.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276564"></a>Setting up a shared repository</h2></div></div></div><p>Another way to collaborate is by using a model similar to that
+details.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276559"></a>Setting up a shared repository</h2></div></div></div><p>Another way to collaborate is by using a model similar to that
commonly used in CVS, where several developers with special rights
all push to and pull from a single shared repository. See
<a href="cvs-migration.txt" target="_top">git for CVS users</a> for instructions on how to
-set this up.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276584"></a>Allow web browsing of a repository</h2></div></div></div><p>The gitweb cgi script provides users an easy way to browse your
+set this up.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276578"></a>Allow web browsing of a repository</h2></div></div></div><p>The gitweb cgi script provides users an easy way to browse your
project's files and history without having to install git; see the file
-gitweb/README in the git source tree for instructions on setting it up.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276596"></a>Examples</h2></div></div></div><p>TODO: topic branches, typical roles as in everyday.txt, ?</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="cleaning-up-history"></a>Chapter 6. Rewriting history and maintaining patch series</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id276628">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276703">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276834">Modifying a single commit</a></span></dt><dt><span class="section"><a href="#id276924">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276984">Other tools</a></span></dt><dt><span class="section"><a href="#id276997">Problems with rewriting history</a></span></dt></dl></div><p>Normally commits are only added to a project, never taken away or
+gitweb/README in the git source tree for instructions on setting it up.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276591"></a>Examples</h2></div></div></div><p>TODO: topic branches, typical roles as in everyday.txt, ?</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="cleaning-up-history"></a>Chapter 6. Rewriting history and maintaining patch series</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id276623">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276698">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276828">Modifying a single commit</a></span></dt><dt><span class="section"><a href="#id276918">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276978">Other tools</a></span></dt><dt><span class="section"><a href="#id276991">Problems with rewriting history</a></span></dt></dl></div><p>Normally commits are only added to a project, never taken away or
replaced. Git is designed with this assumption, and violating it will
cause git's merge machinery (for example) to do the wrong thing.</p><p>However, there is a situation in which it can be useful to violate this
-assumption.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276628"></a>Creating the perfect patch series</h2></div></div></div><p>Suppose you are a contributor to a large project, and you want to add a
+assumption.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276623"></a>Creating the perfect patch series</h2></div></div></div><p>Suppose you are a contributor to a large project, and you want to add a
complicated feature, and to present it to the other developers in a way
that makes it easy for them to read your changes, verify that they are
correct, and understand why you made each change.</p><p>If you present all of your changes as a single patch (or commit), they
(probably much messier!) development process did.
</li></ol></div><p>We will introduce some tools that can help you do this, explain how to
use them, and then explain some of the problems that can arise because
-you are rewriting history.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276703"></a>Keeping a patch series up to date using git-rebase</h2></div></div></div><p>Suppose that you create a branch "mywork" on a remote-tracking branch
+you are rewriting history.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276698"></a>Keeping a patch series up to date using git-rebase</h2></div></div></div><p>Suppose that you create a branch "mywork" on a remote-tracking branch
"origin", and create some commits on top of it:</p><div class="literallayout"><p>$ git checkout -b mywork origin<br>
$ vi file.txt<br>
$ git commit<br>
$ vi otherfile.txt<br>
$ git commit<br>
...</p></div><p>You have performed no merges into mywork, so it is just a simple linear
-sequence of patches on top of "origin":</p><pre class="literallayout">o--o--o <-- origin
- o--o--o <-- mywork</pre><p>Some more interesting work has been done in the upstream project, and
-"origin" has advanced:</p><pre class="literallayout">o--o--O--o--o--o <-- origin
- a--b--c <-- mywork</pre><p>At this point, you could use "pull" to merge your changes back in;
-the result would create a new merge commit, like this:</p><pre class="literallayout">o--o--O--o--o--o <-- origin
- \ a--b--c--m <-- mywork</pre><p>However, if you prefer to keep the history in mywork a simple series of
+sequence of patches on top of "origin":</p><pre class="literallayout"> o--o--o <-- origin
+ \
+ o--o--o <-- mywork</pre><p>Some more interesting work has been done in the upstream project, and
+"origin" has advanced:</p><pre class="literallayout"> o--o--O--o--o--o <-- origin
+ \
+ a--b--c <-- mywork</pre><p>At this point, you could use "pull" to merge your changes back in;
+the result would create a new merge commit, like this:</p><pre class="literallayout"> o--o--O--o--o--o <-- origin
+ \ \
+ a--b--c--m <-- mywork</pre><p>However, if you prefer to keep the history in mywork a simple series of
commits without any merges, you may instead choose to use
<a href="git-rebase.html" target="_top">git-rebase(1)</a>:</p><div class="literallayout"><p>$ git checkout mywork<br>
$ git rebase origin</p></div><p>This will remove each of your commits from mywork, temporarily saving
them as patches (in a directory named ".dotest"), update mywork to
point at the latest version of origin, then apply each of the saved
-patches to the new mywork. The result will look like:</p><pre class="literallayout">o--o--O--o--o--o <-- origin
- a'--b'--c' <-- mywork</pre><p>In the process, it may discover conflicts. In that case it will stop
+patches to the new mywork. The result will look like:</p><pre class="literallayout"> o--o--O--o--o--o <-- origin
+ \
+ a'--b'--c' <-- mywork</pre><p>In the process, it may discover conflicts. In that case it will stop
and allow you to fix the conflicts; after fixing conflicts, use "git
add" to update the index with those contents, and then, instead of
running git-commit, just run</p><div class="literallayout"><p>$ git rebase --continue</p></div><p>and git will continue applying the rest of the patches.</p><p>At any point you may use the —abort option to abort this process and
-return mywork to the state it had before you started the rebase:</p><div class="literallayout"><p>$ git rebase --abort</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276834"></a>Modifying a single commit</h2></div></div></div><p>We saw in <a href="#fixing-a-mistake-by-editing-history" title="Fixing a mistake by editing history">the section called “Fixing a mistake by editing history”</a> that you can replace the
+return mywork to the state it had before you started the rebase:</p><div class="literallayout"><p>$ git rebase --abort</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276828"></a>Modifying a single commit</h2></div></div></div><p>We saw in <a href="#fixing-a-mistake-by-editing-history" title="Fixing a mistake by editing history">the section called “Fixing a mistake by editing history”</a> that you can replace the
most recent commit using</p><div class="literallayout"><p>$ git commit --amend</p></div><p>which will replace the old commit by a new commit incorporating your
changes, giving you a chance to edit the old commit message first.</p><p>You can also use a combination of this and <a href="git-rebase.html" target="_top">git-rebase(1)</a> to edit
commits further back in your history. First, tag the problematic commit with</p><div class="literallayout"><p>$ git tag bad mywork~5</p></div><p>(Either gitk or git-log may be useful for finding the commit.)</p><p>Then check out a new branch at that commit, edit it, and rebase the rest of
then clean up with</p><div class="literallayout"><p>$ git branch -d TMP<br>
$ git tag -d bad</p></div><p>Note that the immutable nature of git history means that you haven't really
"modified" existing commits; instead, you have replaced the old commits with
-new commits having new object names.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276924"></a>Reordering or selecting from a patch series</h2></div></div></div><p>Given one existing commit, the <a href="git-cherry-pick.html" target="_top">git-cherry-pick(1)</a> command
+new commits having new object names.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276918"></a>Reordering or selecting from a patch series</h2></div></div></div><p>Given one existing commit, the <a href="git-cherry-pick.html" target="_top">git-cherry-pick(1)</a> command
allows you to apply the change introduced by that commit and create a
new commit that records it. So, for example, if "mywork" points to a
series of patches on top of "origin", you might do something like:</p><div class="literallayout"><p>$ git checkout -b mywork-new origin<br>
—amend.</p><p>Another technique is to use git-format-patch to create a series of
patches, then reset the state to before the patches:</p><div class="literallayout"><p>$ git format-patch origin<br>
$ git reset --hard origin</p></div><p>Then modify, reorder, or eliminate patches as preferred before applying
-them again with <a href="git-am.html" target="_top">git-am(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276984"></a>Other tools</h2></div></div></div><p>There are numerous other tools, such as stgit, which exist for the
+them again with <a href="git-am.html" target="_top">git-am(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276978"></a>Other tools</h2></div></div></div><p>There are numerous other tools, such as stgit, which exist for the
purpose of maintaining a patch series. These are outside of the scope of
-this manual.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276997"></a>Problems with rewriting history</h2></div></div></div><p>The primary problem with rewriting the history of a branch has to do
+this manual.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276991"></a>Problems with rewriting history</h2></div></div></div><p>The primary problem with rewriting the history of a branch has to do
with merging. Suppose somebody fetches your branch and merges it into
-their branch, with a result something like this:</p><pre class="literallayout">o--o--O--o--o--o <-- origin
- \ t--t--t--m <-- their branch:</pre><p>Then suppose you modify the last three commits:</p><pre class="literallayout"> o--o--o <-- new head of origin
- /
-o--o--O--o--o--o <-- old head of origin</pre><p>If we examined all this history together in one repository, it will
-look like:</p><pre class="literallayout"> o--o--o <-- new head of origin
- /
-o--o--O--o--o--o <-- old head of origin
- \ t--t--t--m <-- their branch:</pre><p>Git has no way of knowing that the new head is an updated version of
+their branch, with a result something like this:</p><pre class="literallayout"> o--o--O--o--o--o <-- origin
+ \ \
+ t--t--t--m <-- their branch:</pre><p>Then suppose you modify the last three commits:</p><pre class="literallayout"> o--o--o <-- new head of origin
+ /
+ o--o--O--o--o--o <-- old head of origin</pre><p>If we examined all this history together in one repository, it will
+look like:</p><pre class="literallayout"> o--o--o <-- new head of origin
+ /
+ o--o--O--o--o--o <-- old head of origin
+ \ \
+ t--t--t--m <-- their branch:</pre><p>Git has no way of knowing that the new head is an updated version of
the old head; it treats this situation exactly the same as it would if
two developers had independently done the work on the old and new heads
in parallel. At this point, if someone attempts to merge the new head
and it may be useful for others to be able to fetch those branches in
order to examine or test them, but they should not attempt to pull such
branches into their own work.</p><p>For true distributed development that supports proper merging,
-published branches should never be rewritten.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id277069"></a>Chapter 7. Advanced branch management</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id277075">Fetching individual branches</a></span></dt><dt><span class="section"><a href="#fast-forwards">Understanding git history: fast-forwards</a></span></dt><dt><span class="section"><a href="#id277195">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277222">Configuring remote branches</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277075"></a>Fetching individual branches</h2></div></div></div><p>Instead of using <a href="git-remote.html" target="_top">git-remote(1)</a>, you can also choose just
+published branches should never be rewritten.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id277062"></a>Chapter 7. Advanced branch management</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id277068">Fetching individual branches</a></span></dt><dt><span class="section"><a href="#fast-forwards">Understanding git history: fast-forwards</a></span></dt><dt><span class="section"><a href="#id277188">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277215">Configuring remote branches</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277068"></a>Fetching individual branches</h2></div></div></div><p>Instead of using <a href="git-remote.html" target="_top">git-remote(1)</a>, you can also choose just
to update one branch at a time, and to store it locally under an
arbitrary name:</p><div class="literallayout"><p>$ git fetch origin todo:my-todo-work</p></div><p>The first argument, "origin", just tells git to fetch from the
repository you originally cloned from. The second argument tells git
fetch" checks to make sure that the most recent commit on the remote
branch is a descendant of the most recent commit on your copy of the
branch before updating your copy of the branch to point at the new
-commit. Git calls this process a "fast forward".</p><p>A fast forward looks something like this:</p><pre class="literallayout">o--o--o--o <-- old head of the branch
- o--o--o <-- new head of the branch</pre><p>In some cases it is possible that the new head will <span class="strong"><strong>not</strong></span> actually be
+commit. Git calls this process a "fast forward".</p><p>A fast forward looks something like this:</p><pre class="literallayout"> o--o--o--o <-- old head of the branch
+ \
+ o--o--o <-- new head of the branch</pre><p>In some cases it is possible that the new head will <span class="strong"><strong>not</strong></span> actually be
a descendant of the old head. For example, the developer may have
realized she made a serious mistake, and decided to backtrack,
-resulting in a situation like:</p><pre class="literallayout">o--o--o--o--a--b <-- old head of the branch
- o--o--o <-- new head of the branch</pre><p>In this case, "git fetch" will fail, and print out a warning.</p><p>In that case, you can still force git to update to the new head, as
+resulting in a situation like:</p><pre class="literallayout"> o--o--o--o--a--b <-- old head of the branch
+ \
+ o--o--o <-- new head of the branch</pre><p>In this case, "git fetch" will fail, and print out a warning.</p><p>In that case, you can still force git to update to the new head, as
described in the following section. However, note that in the
situation above this may mean losing the commits labeled "a" and "b",
unless you've already created a reference of your own pointing to
-them.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277195"></a>Forcing git fetch to do non-fast-forward updates</h2></div></div></div><p>If git fetch fails because the new head of a branch is not a
+them.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277188"></a>Forcing git fetch to do non-fast-forward updates</h2></div></div></div><p>If git fetch fails because the new head of a branch is not a
descendant of the old head, you may force the update with:</p><div class="literallayout"><p>$ git fetch git://example.com/proj.git +master:refs/remotes/example/master</p></div><p>Note the addition of the "+" sign. Be aware that commits that the
old version of example/master pointed at may be lost, as we saw in
-the previous section.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277222"></a>Configuring remote branches</h2></div></div></div><p>We saw above that "origin" is just a shortcut to refer to the
+the previous section.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277215"></a>Configuring remote branches</h2></div></div></div><p>We saw above that "origin" is just a shortcut to refer to the
repository that you originally cloned from. This information is
stored in git configuration variables, which you can see using
<a href="git-config.html" target="_top">git-config(1)</a>:</p><div class="literallayout"><p>$ git config -l<br>
throwing away commits on mybranch.</p><p>Also note that all of the above configuration can be performed by
directly editing the file .git/config instead of using
<a href="git-config.html" target="_top">git-config(1)</a>.</p><p>See <a href="git-config.html" target="_top">git-config(1)</a> for more details on the configuration
-options mentioned above.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="git-internals"></a>Chapter 8. Git internals</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id277360">The Object Database</a></span></dt><dt><span class="section"><a href="#id277475">Blob Object</a></span></dt><dt><span class="section"><a href="#id277519">Tree Object</a></span></dt><dt><span class="section"><a href="#id277596">Commit Object</a></span></dt><dt><span class="section"><a href="#id277643">Trust</a></span></dt><dt><span class="section"><a href="#id277694">Tag Object</a></span></dt><dt><span class="section"><a href="#id277740">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277815">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277834">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277923">index -> object database</a></span></dt><dt><span class="section"><a href="#id277952">object database -> index</a></span></dt><dt><span class="section"><a href="#id277982">index -> working directory</a></span></dt><dt><span class="section"><a href="#id278046">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278141">Examining the data</a></span></dt><dt><span class="section"><a href="#id278219">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278306">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278566">How git stores objects efficiently: pack files</a></span></dt><dt><span class="section"><a href="#dangling-objects">Dangling objects</a></span></dt></dl></div><p>There are two object abstractions: the "object database", and the
-"current directory cache" aka "index".</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277360"></a>The Object Database</h2></div></div></div><p>The object database is literally just a content-addressable collection
+options mentioned above.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="git-internals"></a>Chapter 8. Git internals</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id277353">The Object Database</a></span></dt><dt><span class="section"><a href="#id277469">Blob Object</a></span></dt><dt><span class="section"><a href="#id277512">Tree Object</a></span></dt><dt><span class="section"><a href="#id232240">Commit Object</a></span></dt><dt><span class="section"><a href="#id277705">Trust</a></span></dt><dt><span class="section"><a href="#id277755">Tag Object</a></span></dt><dt><span class="section"><a href="#id277801">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277877">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277895">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277985">index -> object database</a></span></dt><dt><span class="section"><a href="#id278013">object database -> index</a></span></dt><dt><span class="section"><a href="#id278044">index -> working directory</a></span></dt><dt><span class="section"><a href="#id278108">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278202">Examining the data</a></span></dt><dt><span class="section"><a href="#id278280">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278368">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278628">How git stores objects efficiently: pack files</a></span></dt><dt><span class="section"><a href="#dangling-objects">Dangling objects</a></span></dt></dl></div><p>There are two object abstractions: the "object database", and the
+"current directory cache" aka "index".</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277353"></a>The Object Database</h2></div></div></div><p>The object database is literally just a content-addressable collection
of objects. All objects are named by their content, which is
approximated by the SHA1 hash of the object itself. Objects may refer
to other objects (by referencing their SHA1 hash), and so you can
connectivity to other objects verified. This is generally done with
the <code class="literal">git-fsck</code> program, which generates a full dependency graph
of all objects, and verifies their internal consistency (in addition
-to just verifying their superficial consistency through the hash).</p><p>The object types in some more detail:</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277475"></a>Blob Object</h2></div></div></div><p>A "blob" object is nothing but a binary blob of data, and doesn't
+to just verifying their superficial consistency through the hash).</p><p>The object types in some more detail:</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277469"></a>Blob Object</h2></div></div></div><p>A "blob" object is nothing but a binary blob of data, and doesn't
refer to anything else. There is no signature or any other
verification of the data, so while the object is consistent (it <span class="emphasis"><em>is</em></span>
indexed by its sha1 hash, so the data itself is certainly correct), it
object. The object is totally independent of its location in the
directory tree, and renaming a file does not change the object that
file is associated with in any way.</p><p>A blob is typically created when <a href="git-update-index.html" target="_top">git-update-index(1)</a>
-is run, and its data can be accessed by <a href="git-cat-file.html" target="_top">git-cat-file(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277519"></a>Tree Object</h2></div></div></div><p>The next hierarchical object type is the "tree" object. A tree object
+is run, and its data can be accessed by <a href="git-cat-file.html" target="_top">git-cat-file(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277512"></a>Tree Object</h2></div></div></div><p>The next hierarchical object type is the "tree" object. A tree object
is a list of mode/name/blob data, sorted by name. Alternatively, the
mode data may specify a directory mode, in which case instead of
naming a blob, that name is associated with another TREE object.</p><p>Like the "blob" object, a tree object is uniquely determined by the
noticing that the blob stayed the same. However, renames with data
changes need a smarter "diff" implementation.</p><p>A tree is created with <a href="git-write-tree.html" target="_top">git-write-tree(1)</a> and
its data can be accessed by <a href="git-ls-tree.html" target="_top">git-ls-tree(1)</a>.
-Two trees can be compared with <a href="git-diff-tree.html" target="_top">git-diff-tree(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277596"></a>Commit Object</h2></div></div></div><p>The "commit" object is an object that introduces the notion of
+Two trees can be compared with <a href="git-diff-tree.html" target="_top">git-diff-tree(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id232240"></a>Commit Object</h2></div></div></div><p>The "commit" object is an object that introduces the notion of
history into the picture. In contrast to the other objects, it
doesn't just describe the physical state of a tree, it describes how
we got there, and why.</p><p>A "commit" is defined by the tree-object that it results in, the
implicit in the trees involved (the result tree, and the result trees
of the parents), and describing that makes no sense in this idiotic
file manager.</p><p>A commit is created with <a href="git-commit-tree.html" target="_top">git-commit-tree(1)</a> and
-its data can be accessed by <a href="git-cat-file.html" target="_top">git-cat-file(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277643"></a>Trust</h2></div></div></div><p>An aside on the notion of "trust". Trust is really outside the scope
+its data can be accessed by <a href="git-cat-file.html" target="_top">git-cat-file(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277705"></a>Trust</h2></div></div></div><p>An aside on the notion of "trust". Trust is really outside the scope
of "git", but it's worth noting a few things. First off, since
everything is hashed with SHA1, you <span class="emphasis"><em>can</em></span> trust that an object is
intact and has not been messed with by external sources. So the name
commits tells others that they can trust the whole history.</p><p>In other words, you can easily validate a whole archive by just
sending out a single email that tells the people the name (SHA1 hash)
of the top commit, and digitally sign that email using something
-like GPG/PGP.</p><p>To assist in this, git also provides the tag object…</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277694"></a>Tag Object</h2></div></div></div><p>Git provides the "tag" object to simplify creating, managing and
+like GPG/PGP.</p><p>To assist in this, git also provides the tag object…</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277755"></a>Tag Object</h2></div></div></div><p>Git provides the "tag" object to simplify creating, managing and
exchanging symbolic and signed tokens. The "tag" object at its
simplest simply symbolically identifies another object by containing
the sha1, type and symbolic name.</p><p>However it can optionally contain additional signature information
verification) has to come from outside.</p><p>A tag is created with <a href="git-mktag.html" target="_top">git-mktag(1)</a>,
its data can be accessed by <a href="git-cat-file.html" target="_top">git-cat-file(1)</a>,
and the signature can be verified by
-<a href="git-verify-tag.html" target="_top">git-verify-tag(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277740"></a>The "index" aka "Current Directory Cache"</h2></div></div></div><p>The index is a simple binary file, which contains an efficient
+<a href="git-verify-tag.html" target="_top">git-verify-tag(1)</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277801"></a>The "index" aka "Current Directory Cache"</h2></div></div></div><p>The index is a simple binary file, which contains an efficient
representation of a virtual directory content at some random time. It
does so by a simple array that associates a set of names, dates,
permissions and content (aka "blob") objects together. The cache is
the index file can have the representation of an intermediate tree that
has not yet been instantiated. So the index can be thought of as a
write-back cache, which can contain dirty information that has not yet
-been written back to the backing store.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277815"></a>The Workflow</h2></div></div></div><p>Generally, all "git" operations work on the index file. Some operations
+been written back to the backing store.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277877"></a>The Workflow</h2></div></div></div><p>Generally, all "git" operations work on the index file. Some operations
work <span class="strong"><strong>purely</strong></span> on the index file (showing the current state of the
index), but most operations move data to and from the index file. Either
from the database or from the working directory. Thus there are four
-main combinations:</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id277834"></a>working directory -> index</h3></div></div></div><p>You update the index with information from the working directory with
+main combinations:</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id277895"></a>working directory -> index</h3></div></div></div><p>You update the index with information from the working directory with
the <a href="git-update-index.html" target="_top">git-update-index(1)</a> command. You
generally update the index information by just specifying the filename
you want to update, like so:</p><div class="literallayout"><p>$ git-update-index filename</p></div><p>but to avoid common mistakes with filename globbing etc, the command
will refresh the "stat" information of each index to match the current
stat information. It will <span class="emphasis"><em>not</em></span> update the object status itself, and
it will only update the fields that are used to quickly test whether
-an object still matches its old backing store object.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id277923"></a>index -> object database</h3></div></div></div><p>You write your current index file to a "tree" object with the program</p><div class="literallayout"><p>$ git-write-tree</p></div><p>that doesn't come with any options - it will just write out the
+an object still matches its old backing store object.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id277985"></a>index -> object database</h3></div></div></div><p>You write your current index file to a "tree" object with the program</p><div class="literallayout"><p>$ git-write-tree</p></div><p>that doesn't come with any options - it will just write out the
current index into the set of tree objects that describe that state,
and it will return the name of the resulting top-level tree. You can
use that tree to re-generate the index at any time by going in the
-other direction:</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id277952"></a>object database -> index</h3></div></div></div><p>You read a "tree" file from the object database, and use that to
+other direction:</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id278013"></a>object database -> index</h3></div></div></div><p>You read a "tree" file from the object database, and use that to
populate (and overwrite - don't do this if your index contains any
unsaved state that you might want to restore later!) your current
index. Normal operation is just</p><div class="literallayout"><p>$ git-read-tree <sha1 of tree></p></div><p>and your index file will now be equivalent to the tree that you saved
earlier. However, that is only your <span class="emphasis"><em>index</em></span> file: your working
-directory contents have not been modified.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id277982"></a>index -> working directory</h3></div></div></div><p>You update your working directory from the index by "checking out"
+directory contents have not been modified.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id278044"></a>index -> working directory</h3></div></div></div><p>You update your working directory from the index by "checking out"
files. This is not a very common operation, since normally you'd just
keep your files updated, and rather than write to your working
directory, you'd tell the index files about the changes in your
if you have an old version of the tree already checked out, you will
need to use the "-f" flag (<span class="emphasis"><em>before</em></span> the "-a" flag or the filename) to
<span class="emphasis"><em>force</em></span> the checkout.</p><p>Finally, there are a few odds and ends which are not purely moving
-from one representation to the other:</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id278046"></a>Tying it all together</h3></div></div></div><p>To commit a tree you have instantiated with "git-write-tree", you'd
+from one representation to the other:</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id278108"></a>Tying it all together</h3></div></div></div><p>To commit a tree you have instantiated with "git-write-tree", you'd
create a "commit" object that refers to that tree and the history
behind it - most notably the "parent" commits that preceded it in
history.</p><p>Normally a "commit" has one parent: the previous state of the tree
| Working |<br>
| Directory |<br>
+-----------+<br>
-</p></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278141"></a>Examining the data</h2></div></div></div><p>You can examine the data represented in the object database and the
+</p></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278202"></a>Examining the data</h2></div></div></div><p>You can examine the data represented in the object database and the
index with various helper tools. For every object, you can use
<a href="git-cat-file.html" target="_top">git-cat-file(1)</a> to examine details about the
object:</p><div class="literallayout"><p>$ git-cat-file -t <objectname></p></div><p>shows the type of the object, and once you have the type (which is
readable form.</p><p>It's especially instructive to look at "commit" objects, since those
tend to be small and fairly self-explanatory. In particular, if you
follow the convention of having the top commit name in <code class="literal">.git/HEAD</code>,
-you can do</p><div class="literallayout"><p>$ git-cat-file commit HEAD</p></div><p>to see what the top commit was.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278219"></a>Merging multiple trees</h2></div></div></div><p>Git helps you do a three-way merge, which you can expand to n-way by
+you can do</p><div class="literallayout"><p>$ git-cat-file commit HEAD</p></div><p>to see what the top commit was.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278280"></a>Merging multiple trees</h2></div></div></div><p>Git helps you do a three-way merge, which you can expand to n-way by
repeating the merge procedure arbitrary times until you finally
"commit" the state. The normal situation is that you'd only do one
three-way merge (two parents), and commit it, but if you like to, you
always do a merge against your last commit (which should thus match what
you have in your current index anyway).</p><p>To do the merge, do</p><div class="literallayout"><p>$ git-read-tree -m -u <origtree> <yourtree> <targettree></p></div><p>which will do all trivial merge operations for you directly in the
index file, and you can just write the result out with
-<code class="literal">git-write-tree</code>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278306"></a>Merging multiple trees, continued</h2></div></div></div><p>Sadly, many merges aren't trivial. If there are files that have
+<code class="literal">git-write-tree</code>.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278368"></a>Merging multiple trees, continued</h2></div></div></div><p>Sadly, many merges aren't trivial. If there are files that have
been added.moved or removed, or if both branches have modified the
same file, you will be left with an index tree that contains "merge
entries" in it. Such an index tree can <span class="emphasis"><em>NOT</em></span> be written out to a tree
to help you understand what conceptually happens under the hood.
In practice, nobody, not even git itself, uses three <code class="literal">git-cat-file</code>
for this. There is <code class="literal">git-merge-index</code> program that extracts the
-stages to temporary files and calls a "merge" script on it:</p><div class="literallayout"><p>$ git-merge-index git-merge-one-file hello.c</p></div><p>and that is what higher level <code class="literal">git merge -s resolve</code> is implemented with.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278566"></a>How git stores objects efficiently: pack files</h2></div></div></div><p>We've seen how git stores each object in a file named after the
+stages to temporary files and calls a "merge" script on it:</p><div class="literallayout"><p>$ git-merge-index git-merge-one-file hello.c</p></div><p>and that is what higher level <code class="literal">git merge -s resolve</code> is implemented with.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id278628"></a>How git stores objects efficiently: pack files</h2></div></div></div><p>We've seen how git stores each object in a file named after the
object's SHA1 hash.</p><p>Unfortunately this system becomes inefficient once a project has a
lot of objects. Try this on an old project:</p><div class="literallayout"><p>$ git count-objects<br>
6930 objects, 47620 kilobytes</p></div><p>The first number is the number of objects which are kept in
Running it while somebody is actually changing the repository can cause
confusing and scary messages, but it won't actually do anything bad. In
contrast, running "git prune" while somebody is actively changing the
-repository is a <span class="strong"><strong>BAD</strong></span> idea).</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id278826"></a>Chapter 9. Glossary of git terms</h2></div></div></div><div class="variablelist"><dl><dt><span class="term">
+repository is a <span class="strong"><strong>BAD</strong></span> idea).</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id278888"></a>Chapter 9. Glossary of git terms</h2></div></div></div><div class="variablelist"><dl><dt><span class="term">
alternate object database
</span></dt><dd>
Via the alternates mechanism, a repository can inherit part of its
</span></dt><dd>
The set of files and directories currently being worked on,
i.e. you can work in your working tree without using git at all.
-</dd></dl></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id280073"></a>Chapter 10. Notes and todo list for this manual</h2></div></div></div><p>This is a work in progress.</p><p>The basic requirements:
+</dd></dl></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id280134"></a>Chapter 10. Notes and todo list for this manual</h2></div></div></div><p>This is a work in progress.</p><p>The basic requirements:
- It must be readable in order, from beginning to end, by
someone intelligent with a basic grasp of the unix
commandline, but without any special knowledge of git. If