-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Git User's Manual</title><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="id232381"></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="#id264754">Preface</a></span></dt><dt><span class="chapter"><a href="#id233103">1. Git Quick Start</a></span></dt><dd><dl><dt><span class="section"><a href="#id233114">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233145">Managing branches</a></span></dt><dt><span class="section"><a href="#id232598">Exploring history</a></span></dt><dt><span class="section"><a href="#id232642">Making changes</a></span></dt><dt><span class="section"><a href="#id233404">Merging</a></span></dt><dt><span class="section"><a href="#id233420">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233504">Repository maintenance</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id232726">2. Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#id232732">How to get a git repository</a></span></dt><dt><span class="section"><a href="#id232788">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#id273450">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#id273500">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#id273540">Undestanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#id273568">Understanding history: What is a branch?</a></span></dt></dl></dd><dt><span class="section"><a href="#id232302">Manipulating branches</a></span></dt><dt><span class="section"><a href="#id273792">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="#id274111">3. Exploring git history</a></span></dt><dd><dl><dt><span class="section"><a href="#id274133">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274253">Naming commits</a></span></dt><dt><span class="section"><a href="#id274503">Creating tags</a></span></dt><dt><span class="section"><a href="#id274539">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274612">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274655">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274682">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274687">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274740">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id274904">4. Developing with git</a></span></dt><dd><dl><dt><span class="section"><a href="#id274909">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274941">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="#id275168">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275184">how to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dt><span class="section"><a href="#undoing-a-merge">undoing a merge</a></span></dt><dt><span class="section"><a href="#id275420">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275449">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275502">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#id275560">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275631">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275689">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275727">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275732">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275807">Recovering lost changes</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id275958">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="#id276090">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276139">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="#id276551">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276570">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276583">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="#id276614">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276689">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276826">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276886">Other tools</a></span></dt><dt><span class="section"><a href="#id276898">Problems with rewriting history</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id276970">7. Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#id276976">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="#id277096">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277123">Configuring remote branches</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id277247">8. Git internals</a></span></dt><dd><dl><dt><span class="section"><a href="#id277258">The Object Database</a></span></dt><dt><span class="section"><a href="#id277374">Blob Object</a></span></dt><dt><span class="section"><a href="#id277417">Tree Object</a></span></dt><dt><span class="section"><a href="#id277495">Commit Object</a></span></dt><dt><span class="section"><a href="#id277541">Trust</a></span></dt><dt><span class="section"><a href="#id277592">Tag Object</a></span></dt><dt><span class="section"><a href="#id277638">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277713">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277732">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277821">index -> object database</a></span></dt><dt><span class="section"><a href="#id277850">object database -> index</a></span></dt><dt><span class="section"><a href="#id277880">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277944">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278039">Examining the data</a></span></dt><dt><span class="section"><a href="#id278117">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278204">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278464">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="#id278724">9. Glossary of git terms</a></span></dt><dt><span class="chapter"><a href="#id279940">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="id264754"></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><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="id232381"></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="#id264754">Preface</a></span></dt><dt><span class="chapter"><a href="#id233103">1. Git Quick Start</a></span></dt><dd><dl><dt><span class="section"><a href="#id233114">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233145">Managing branches</a></span></dt><dt><span class="section"><a href="#id232598">Exploring history</a></span></dt><dt><span class="section"><a href="#id232642">Making changes</a></span></dt><dt><span class="section"><a href="#id233404">Merging</a></span></dt><dt><span class="section"><a href="#id233420">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233504">Repository maintenance</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id232726">2. Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#id232732">How to get a git repository</a></span></dt><dt><span class="section"><a href="#id232788">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#id273450">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#id273500">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#id273540">Undestanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#id273568">Understanding history: What is a branch?</a></span></dt></dl></dd><dt><span class="section"><a href="#id232302">Manipulating branches</a></span></dt><dt><span class="section"><a href="#id273792">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="#id274111">3. Exploring git history</a></span></dt><dd><dl><dt><span class="section"><a href="#id274133">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274253">Naming commits</a></span></dt><dt><span class="section"><a href="#id274503">Creating tags</a></span></dt><dt><span class="section"><a href="#id274539">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274612">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274655">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274682">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274687">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274740">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id274904">4. Developing with git</a></span></dt><dd><dl><dt><span class="section"><a href="#id274909">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274941">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="#id275168">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275184">how to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dt><span class="section"><a href="#undoing-a-merge">undoing a merge</a></span></dt><dt><span class="section"><a href="#id275420">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275449">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275502">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#id275560">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275631">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275689">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275727">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275732">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275807">Recovering lost changes</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id275957">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="#id276089">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276138">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="#id276550">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276569">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276582">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="#id276613">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276688">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276825">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276885">Other tools</a></span></dt><dt><span class="section"><a href="#id276897">Problems with rewriting history</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id276969">7. Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#id276975">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="#id277095">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277122">Configuring remote branches</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id277246">8. Git internals</a></span></dt><dd><dl><dt><span class="section"><a href="#id277257">The Object Database</a></span></dt><dt><span class="section"><a href="#id277373">Blob Object</a></span></dt><dt><span class="section"><a href="#id277416">Tree Object</a></span></dt><dt><span class="section"><a href="#id277494">Commit Object</a></span></dt><dt><span class="section"><a href="#id277540">Trust</a></span></dt><dt><span class="section"><a href="#id277591">Tag Object</a></span></dt><dt><span class="section"><a href="#id277637">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277712">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277731">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277820">index -> object database</a></span></dt><dt><span class="section"><a href="#id277849">object database -> index</a></span></dt><dt><span class="section"><a href="#id277880">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277943">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278038">Examining the data</a></span></dt><dt><span class="section"><a href="#id278116">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278203">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278463">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="#id278723">9. Glossary of git terms</a></span></dt><dt><span class="chapter"><a href="#id279939">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="id264754"></a>Preface</h2></div></div></div><p>This manual is designed to be readable by someone with basic unix
commandline 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
importantly, it is a globally unique name for this commit: so if you
tell somebody else the object name (for example in email), then you are
guaranteed that name will refer to the same commit in their repository
-that you it does in yours (assuming their repository has that commit at
+that it does in yours (assuming their repository has that commit at
all).</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id273500"></a>Understanding history: commits, parents, and reachability</h3></div></div></div><p>Every commit (except the very first commit in a project) also has a
parent commit which shows what happened before this commit.
Following the chain of parents will eventually take you back to the
collection of files. It does this by storing compressed snapshots of
the contents of a file heirarchy, together with "commits" which show
the relationships between these snapshots.</p><p>Git provides extremely flexible and fast tools for exploring the
-history of a project.</p><p>We start with one specialized tool which is useful for finding the
+history of a project.</p><p>We start with one specialized tool that is useful for finding the
commit that introduced a bug into a project.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id274133"></a>How to use bisect to find a regression</h2></div></div></div><p>Suppose version 2.6.18 of your project worked, but the version at
"master" crashes. Sometimes the best way to find the cause of such a
regression is to perform a brute-force search through the project's
dangling commit 7281251ddd2a61e38657c827739c57015671a6b3<br>
dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63<br>
dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5<br>
-...</p></div><p>and watch for output that mentions "dangling commits". You can examine
+...</p></div><p>You can examine
one of those dangling commits with, for example,</p><div class="literallayout"><p>$ gitk 7281251ddd --not --all</p></div><p>which does what it sounds like: it says that you want to see the commit
history that is described by the dangling commit(s), but not the
history that is described by all your existing branches and tags. Thus
(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 gotten 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="id275958"></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="#id276090">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276139">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="#id276551">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276570">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276583">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="id275957"></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="#id276089">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276138">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="#id276550">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276569">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276582">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="id276090"></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="id276089"></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="id276139"></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="id276138"></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="id276551"></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="id276550"></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="id276570"></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="id276569"></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="id276583"></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="#id276614">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276689">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276826">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276886">Other tools</a></span></dt><dt><span class="section"><a href="#id276898">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="id276582"></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="#id276613">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276688">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276825">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276885">Other tools</a></span></dt><dt><span class="section"><a href="#id276897">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="id276614"></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="id276613"></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="id276689"></a>Keeping a patch series up to date using git-rebase</h2></div></div></div><p>Suppose you have a series of commits in a branch "mywork", which
+you are rewriting history.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276688"></a>Keeping a patch series up to date using git-rebase</h2></div></div></div><p>Suppose you have a series of commits in a branch "mywork", which
originally branched off from "origin".</p><p>Suppose you create a branch "mywork" on a remote-tracking branch
"origin", and created some commits on top of it:</p><div class="literallayout"><p>$ git checkout -b mywork origin<br>
$ vi file.txt<br>
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="id276826"></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
+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="id276825"></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="id276886"></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="id276885"></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 out 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="id276898"></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="id276897"></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
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="id276970"></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="#id276976">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="#id277096">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277123">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="id276976"></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="id276969"></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="#id276975">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="#id277095">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277122">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="id276975"></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
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="id277096"></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="id277095"></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 which 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="id277123"></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="id277122"></a>Configuring remote branches</h2></div></div></div><p>We saw above that "origin" is just a shortcut to refer to the
repository which 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="id277247"></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="#id277258">The Object Database</a></span></dt><dt><span class="section"><a href="#id277374">Blob Object</a></span></dt><dt><span class="section"><a href="#id277417">Tree Object</a></span></dt><dt><span class="section"><a href="#id277495">Commit Object</a></span></dt><dt><span class="section"><a href="#id277541">Trust</a></span></dt><dt><span class="section"><a href="#id277592">Tag Object</a></span></dt><dt><span class="section"><a href="#id277638">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277713">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277732">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277821">index -> object database</a></span></dt><dt><span class="section"><a href="#id277850">object database -> index</a></span></dt><dt><span class="section"><a href="#id277880">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277944">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278039">Examining the data</a></span></dt><dt><span class="section"><a href="#id278117">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278204">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278464">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="id277258"></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="id277246"></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="#id277257">The Object Database</a></span></dt><dt><span class="section"><a href="#id277373">Blob Object</a></span></dt><dt><span class="section"><a href="#id277416">Tree Object</a></span></dt><dt><span class="section"><a href="#id277494">Commit Object</a></span></dt><dt><span class="section"><a href="#id277540">Trust</a></span></dt><dt><span class="section"><a href="#id277591">Tag Object</a></span></dt><dt><span class="section"><a href="#id277637">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277712">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277731">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277820">index -> object database</a></span></dt><dt><span class="section"><a href="#id277849">object database -> index</a></span></dt><dt><span class="section"><a href="#id277880">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277943">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278038">Examining the data</a></span></dt><dt><span class="section"><a href="#id278116">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278203">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278463">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="id277257"></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="id277374"></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="id277373"></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="id277417"></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="id277416"></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="id277495"></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="id277494"></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="id277541"></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="id277540"></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="id277592"></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="id277591"></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="id277638"></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="id277637"></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="id277713"></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="id277712"></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="id277732"></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="id277731"></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="id277821"></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="id277820"></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="id277850"></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="id277849"></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
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="id277944"></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="id277943"></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="id278039"></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="id278038"></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="id278117"></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="id278116"></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="id278204"></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="id278203"></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 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="id278464"></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 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="id278463"></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="id278724"></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="id278723"></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="id279940"></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="id279939"></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
no more knowledge than necessary: for example, "importing
patches into a project" rather than "the git-am command"</p><p>Think about how to create a clear chapter dependency graph that will
allow people to get to important topics without necessarily reading
-everything in between.</p><p>Scan Documentation/ for other stuff left out; in particular:
+everything in between.</p><p>Say something about .gitignore.</p><p>Scan Documentation/ for other stuff left out; in particular:
howto's
some of technical/?
hooks