-<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="id189263"></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="#id264751">Preface</a></span></dt><dt><span class="chapter"><a href="#id233181">1. Git Quick Start</a></span></dt><dd><dl><dt><span class="section"><a href="#id233192">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233223">Managing branches</a></span></dt><dt><span class="section"><a href="#id233456">Exploring history</a></span></dt><dt><span class="section"><a href="#id233499">Making changes</a></span></dt><dt><span class="section"><a href="#id232938">Merging</a></span></dt><dt><span class="section"><a href="#id232955">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233039">Repository maintenance</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id232541">2. Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#id232547">How to get a git repository</a></span></dt><dt><span class="section"><a href="#id232603">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#id273448">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#id273497">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#id273537">Understanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#id273565">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="#id273789">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="#id274034">Fetching branches from other repositories</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id274109">3. Exploring git history</a></span></dt><dd><dl><dt><span class="section"><a href="#id274131">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274250">Naming commits</a></span></dt><dt><span class="section"><a href="#id274501">Creating tags</a></span></dt><dt><span class="section"><a href="#id274536">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274610">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274653">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274679">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274685">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274737">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id274901">4. Developing with git</a></span></dt><dd><dl><dt><span class="section"><a href="#id274907">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274938">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="#id275166">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275182">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="#id275418">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275446">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275499">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#id275558">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275628">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275687">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275724">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275730">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275805">Recovering lost changes</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id275955">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="#id276086">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276136">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="#id276548">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276567">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276579">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="#id276611">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276686">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276822">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276882">Other tools</a></span></dt><dt><span class="section"><a href="#id276895">Problems with rewriting history</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id276967">7. Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#id276972">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="#id277093">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277120">Configuring remote branches</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id277244">8. Git internals</a></span></dt><dd><dl><dt><span class="section"><a href="#id277255">The Object Database</a></span></dt><dt><span class="section"><a href="#id277370">Blob Object</a></span></dt><dt><span class="section"><a href="#id277414">Tree Object</a></span></dt><dt><span class="section"><a href="#id277491">Commit Object</a></span></dt><dt><span class="section"><a href="#id277538">Trust</a></span></dt><dt><span class="section"><a href="#id277588">Tag Object</a></span></dt><dt><span class="section"><a href="#id277634">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277710">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277728">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277818">index -> object database</a></span></dt><dt><span class="section"><a href="#id277846">object database -> index</a></span></dt><dt><span class="section"><a href="#id277877">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277941">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278035">Examining the data</a></span></dt><dt><span class="section"><a href="#id278113">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278201">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278461">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="#id278721">9. Glossary of git terms</a></span></dt><dt><span class="chapter"><a href="#id279936">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="id264751"></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
+<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="id189263"></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="#id264751">Preface</a></span></dt><dt><span class="chapter"><a href="#id233181">1. Git Quick Start</a></span></dt><dd><dl><dt><span class="section"><a href="#id233192">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233223">Managing branches</a></span></dt><dt><span class="section"><a href="#id233456">Exploring history</a></span></dt><dt><span class="section"><a href="#id233500">Making changes</a></span></dt><dt><span class="section"><a href="#id232938">Merging</a></span></dt><dt><span class="section"><a href="#id232955">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233039">Repository maintenance</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id232541">2. Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#id232547">How to get a git repository</a></span></dt><dt><span class="section"><a href="#id232603">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#id273448">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#id273497">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#id273537">Understanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#id273565">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="#id273789">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="#id274034">Fetching branches from other repositories</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id274109">3. Exploring git history</a></span></dt><dd><dl><dt><span class="section"><a href="#id274131">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274250">Naming commits</a></span></dt><dt><span class="section"><a href="#id274501">Creating tags</a></span></dt><dt><span class="section"><a href="#id274536">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274610">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274653">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274679">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274685">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274738">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id274901">4. Developing with git</a></span></dt><dd><dl><dt><span class="section"><a href="#id274907">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274939">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="#id275166">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275182">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="#id275418">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275447">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275500">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#id275558">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275628">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275687">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275724">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275730">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275805">Recovering lost changes</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id275955">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="#id276086">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276136">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="#id276548">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276567">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276579">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="#id276611">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276686">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276817">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276878">Other tools</a></span></dt><dt><span class="section"><a href="#id276891">Problems with rewriting history</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id276962">7. Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#id276968">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="#id277088">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277115">Configuring remote branches</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id277239">8. Git internals</a></span></dt><dd><dl><dt><span class="section"><a href="#id277250">The Object Database</a></span></dt><dt><span class="section"><a href="#id277365">Blob Object</a></span></dt><dt><span class="section"><a href="#id277409">Tree Object</a></span></dt><dt><span class="section"><a href="#id277486">Commit Object</a></span></dt><dt><span class="section"><a href="#id277533">Trust</a></span></dt><dt><span class="section"><a href="#id277583">Tag Object</a></span></dt><dt><span class="section"><a href="#id277630">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277705">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277724">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277813">index -> object database</a></span></dt><dt><span class="section"><a href="#id277841">object database -> index</a></span></dt><dt><span class="section"><a href="#id277872">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277936">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278030">Examining the data</a></span></dt><dt><span class="section"><a href="#id278108">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278195">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278455">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="#id278715">9. Glossary of git terms</a></span></dt><dt><span class="chapter"><a href="#id279930">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="id264751"></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
software project, to search for regressions, and so on.</p><p>Chapter 4 explains how to do development with git, and chapter 5 how
to share that development with others.</p><p>Further chapters cover more specialized topics.</p><p>Comprehensive reference documentation is available through the man
-pages. For a command such as "git clone", just use</p><div class="literallayout"><p>$ man git-clone</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id233181"></a>Chapter 1. Git Quick Start</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id233192">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233223">Managing branches</a></span></dt><dt><span class="section"><a href="#id233456">Exploring history</a></span></dt><dt><span class="section"><a href="#id233499">Making changes</a></span></dt><dt><span class="section"><a href="#id232938">Merging</a></span></dt><dt><span class="section"><a href="#id232955">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233039">Repository maintenance</a></span></dt></dl></div><p>This is a quick summary of the major commands; the following chapters
+pages. For a command such as "git clone", just use</p><div class="literallayout"><p>$ man git-clone</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id233181"></a>Chapter 1. Git Quick Start</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id233192">Creating a new repository</a></span></dt><dt><span class="section"><a href="#id233223">Managing branches</a></span></dt><dt><span class="section"><a href="#id233456">Exploring history</a></span></dt><dt><span class="section"><a href="#id233500">Making changes</a></span></dt><dt><span class="section"><a href="#id232938">Merging</a></span></dt><dt><span class="section"><a href="#id232955">Sharing your changes</a></span></dt><dt><span class="section"><a href="#id233039">Repository maintenance</a></span></dt></dl></div><p>This is a quick summary of the major commands; the following chapters
will explain how these work in more detail.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id233192"></a>Creating a new repository</h2></div></div></div><p>From a tarball:</p><div class="literallayout"><p>$ tar xzf project.tar.gz<br>
$ cd project<br>
$ git init<br>
# test here, then:<br>
$ git bisect good # if this revision is good, or<br>
$ git bisect bad # if this revision is bad.<br>
- # repeat until done.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id233499"></a>Making changes</h2></div></div></div><p>Make sure git knows who to blame:</p><div class="literallayout"><p>$ cat >~/.gitconfig <<\EOF<br>
+ # repeat until done.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id233500"></a>Making changes</h2></div></div></div><p>Make sure git knows who to blame:</p><div class="literallayout"><p>$ cat >~/.gitconfig <<\EOF<br>
[user]<br>
name = Your Name Comes Here<br>
email = you@yourdomain.example.com<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
-<a href="git-config.html" target="_top">git-config(1)</a> for details.)</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id274109"></a>Chapter 3. Exploring git history</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id274131">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274250">Naming commits</a></span></dt><dt><span class="section"><a href="#id274501">Creating tags</a></span></dt><dt><span class="section"><a href="#id274536">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274610">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274653">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274679">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274685">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274737">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></div><p>Git is best thought of as a tool for storing the history of a
+<a href="git-config.html" target="_top">git-config(1)</a> for details.)</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id274109"></a>Chapter 3. Exploring git history</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#id274131">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#id274250">Naming commits</a></span></dt><dt><span class="section"><a href="#id274501">Creating tags</a></span></dt><dt><span class="section"><a href="#id274536">Browsing revisions</a></span></dt><dt><span class="section"><a href="#id274610">Generating diffs</a></span></dt><dt><span class="section"><a href="#id274653">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#id274679">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#id274685">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#id274738">Find first tagged version including a given fix</a></span></dt></dl></dd></dl></div><p>Git is best thought of as a tool for storing the history of a
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
$ git rev-list master<br>
e05db0fd4f31dde7005f075a84f96b360d05984b</p></div><p>Or you could recall that the … operator selects all commits
contained reachable from either one reference or the other but not
-both: so</p><div class="literallayout"><p>$ git log origin...master</p></div><p>will return no commits when the two branches are equal.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id274737"></a>Find first tagged version including a given fix</h3></div></div></div><p>Suppose you know that the commit e05db0fd fixed a certain problem.
+both: so</p><div class="literallayout"><p>$ git log origin...master</p></div><p>will return no commits when the two branches are equal.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id274738"></a>Find first tagged version including a given fix</h3></div></div></div><p>Suppose you know that the commit e05db0fd fixed a certain problem.
You'd like to find the earliest tagged release that contains that
fix.</p><p>Of course, there may be more than one answer—if the history branched
after commit e05db0fd, then there could be multiple "earliest" tagged
! [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="id274901"></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="#id274907">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274938">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="#id275166">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275182">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="#id275418">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275446">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275499">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#id275558">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275628">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275687">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275724">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275730">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275805">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="id274907"></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="id274901"></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="#id274907">Telling git your name</a></span></dt><dt><span class="section"><a href="#id274939">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="#id275166">creating good commit messages</a></span></dt><dt><span class="section"><a href="#id275182">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="#id275418">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#id275447">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#id275500">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#id275558">Fixing a mistake by editing history</a></span></dt><dt><span class="section"><a href="#id275628">Checking out an old version of a file</a></span></dt></dl></dd><dt><span class="section"><a href="#id275687">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#id275724">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#id275730">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#id275805">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="id274907"></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>
email = you@yourdomain.example.com<br>
EOF</p></div><p>(See the "CONFIGURATION FILE" section of <a href="git-config.html" target="_top">git-config(1)</a> for
-details on the configuration file.)</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id274938"></a>Creating a new repository</h2></div></div></div><p>Creating a new repository from scratch is very easy:</p><div class="literallayout"><p>$ mkdir project<br>
+details on the configuration file.)</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id274939"></a>Creating a new repository</h2></div></div></div><p>Creating a new repository from scratch is very easy:</p><div class="literallayout"><p>$ mkdir project<br>
$ cd project<br>
$ git init</p></div><p>If you have some initial content (say, a tarball):</p><div class="literallayout"><p>$ tar -xzvf project.tar.gz<br>
$ cd project<br>
conflict will have two parents instead of the usual one: one parent
will be HEAD, the tip of the current branch; the other will be the
tip of the other branch, which is stored temporarily in MERGE_HEAD.</p><p>The diff above shows the differences between the working-tree version
-of file.txt and two previous version: one version from HEAD, and one
+of file.txt and two previous versions: one version from HEAD, and one
from MERGE_HEAD. So instead of preceding each line by a single "+"
or "-", it now uses two columns: the first column is used for
differences between the first parent and the working directory copy,
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="id275446"></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="id275447"></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="id275499"></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="id275500"></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
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="id275805"></a>Recovering lost changes</h3></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id275810"></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="id275805"></a>Recovering lost changes</h3></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id275811"></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="id275888"></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="id275889"></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 pointed you. The reflog is also deleted; however, if you have not
+it contained. The reflog is also deleted; however, if you have not
yet pruned the repository, then you may still be able to find
the lost commits; run git-fsck and watch for output that mentions
"dangling commits":</p><div class="literallayout"><p>$ git fsck<br>
you get exactly the history reachable from that commit that is lost.
(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
+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="id275955"></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="#id276086">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#id276136">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="#id276548">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#id276567">Allow web browsing of a repository</a></span></dt><dt><span class="section"><a href="#id276579">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>,
producing a default commit message documenting the branch and
repository that you pulled from.</p><p>(But note that no such commit will be created in the case of a
<a href="#fast-forwards" title="Understanding git history: fast-forwards">fast forward</a>; instead, your branch will just be
-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,
+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="id276086"></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
maintainer of that project to pull from your repository, exactly as
you did in the section "<a href="#getting-updates-with-git-pull" title="Getting updates with git pull">Getting updates with git pull</a>".</p><p>If you and maintainer both have accounts on the same machine, then
then you can just pull changes from each other's repositories
-directly; note that all of the command (<a href="git-clone.html" target="_top">git-clone(1)</a>,
-git-fetch[1], git-pull[1], etc.) which accept a URL as an argument
+directly; note that all of the commands (<a href="git-clone.html" target="_top">git-clone(1)</a>,
+git-fetch[1], git-pull[1], etc.) that accept a URL as an argument
will also accept a local file patch; so, for example, you can
use</p><div class="literallayout"><p>$ git clone /path/to/repository<br>
$ git pull /path/to/other/repository</p></div><p>If this sort of setup is inconvenient or impossible, another (more
<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="id276567"></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="id276579"></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="#id276611">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276686">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276822">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276882">Other tools</a></span></dt><dt><span class="section"><a href="#id276895">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="id276579"></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="#id276611">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#id276686">Keeping a patch series up to date using git-rebase</a></span></dt><dt><span class="section"><a href="#id276817">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#id276878">Other tools</a></span></dt><dt><span class="section"><a href="#id276891">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="id276611"></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
-may find it is too much to digest all at once.</p><p>If you present them with the entire history of your work, complete with
+may find that it is too much to digest all at once.</p><p>If you present them with the entire history of your work, complete with
mistakes, corrections, and dead ends, they may be overwhelmed.</p><p>So the ideal is usually to produce a series of patches such that:</p><div class="orderedlist"><ol type="1"><li>
Each patch can be applied in order.
</li><li>
(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="id276686"></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>
+you are rewriting history.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id276686"></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>
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="id276822"></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="id276817"></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="id276882"></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="id276895"></a>Problems with rewriting history</h2></div></div></div><p>The primary problem with rewriting the history of a branch has to do
+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="id276878"></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="id276891"></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="id276967"></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="#id276972">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="#id277093">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277120">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="id276972"></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="id276962"></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="#id276968">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="#id277088">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#id277115">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="id276968"></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="id277093"></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
+them.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277088"></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="id277120"></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
+the previous section.</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id277115"></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>
core.repositoryformatversion=0<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="id277244"></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="#id277255">The Object Database</a></span></dt><dt><span class="section"><a href="#id277370">Blob Object</a></span></dt><dt><span class="section"><a href="#id277414">Tree Object</a></span></dt><dt><span class="section"><a href="#id277491">Commit Object</a></span></dt><dt><span class="section"><a href="#id277538">Trust</a></span></dt><dt><span class="section"><a href="#id277588">Tag Object</a></span></dt><dt><span class="section"><a href="#id277634">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277710">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277728">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277818">index -> object database</a></span></dt><dt><span class="section"><a href="#id277846">object database -> index</a></span></dt><dt><span class="section"><a href="#id277877">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277941">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278035">Examining the data</a></span></dt><dt><span class="section"><a href="#id278113">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278201">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278461">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="id277255"></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="id277239"></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="#id277250">The Object Database</a></span></dt><dt><span class="section"><a href="#id277365">Blob Object</a></span></dt><dt><span class="section"><a href="#id277409">Tree Object</a></span></dt><dt><span class="section"><a href="#id277486">Commit Object</a></span></dt><dt><span class="section"><a href="#id277533">Trust</a></span></dt><dt><span class="section"><a href="#id277583">Tag Object</a></span></dt><dt><span class="section"><a href="#id277630">The "index" aka "Current Directory Cache"</a></span></dt><dt><span class="section"><a href="#id277705">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#id277724">working directory -> index</a></span></dt><dt><span class="section"><a href="#id277813">index -> object database</a></span></dt><dt><span class="section"><a href="#id277841">object database -> index</a></span></dt><dt><span class="section"><a href="#id277872">index -> working directory</a></span></dt><dt><span class="section"><a href="#id277936">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#id278030">Examining the data</a></span></dt><dt><span class="section"><a href="#id278108">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#id278195">Merging multiple trees, continued</a></span></dt><dt><span class="section"><a href="#id278455">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="id277250"></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="id277370"></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="id277365"></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="id277414"></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="id277409"></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="id277491"></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="id277486"></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="id277538"></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="id277533"></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="id277588"></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="id277583"></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="id277634"></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="id277630"></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
current state.</em></span></p><p><span class="emphasis"><em>(c) it can additionally efficiently represent information about merge
conflicts between different tree objects, allowing each pathname to be
associated with sufficient information about the trees involved that
-you can create a three-way merge between them.</em></span></p><p>Those are the three ONLY things that the directory cache does. It's a
+you can create a three-way merge between them.</em></span></p><p>Those are the ONLY three things that the directory cache does. It's a
cache, and the normal operation is to re-generate it completely from a
known tree object, or update/compare it with a live tree that is being
developed. If you blow the directory cache away entirely, you generally
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="id277710"></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="id277705"></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="id277728"></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="id277724"></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="id277818"></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="id277813"></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="id277846"></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="id277841"></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="id277877"></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="id277872"></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="id277941"></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="id277936"></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="id278035"></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="id278030"></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="id278113"></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="id278108"></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="id278201"></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="id278195"></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="id278461"></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="id278455"></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="id278721"></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="id278715"></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="id279936"></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="id279930"></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