diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-19 15:33:31 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-19 15:33:31 -0800 |
commit | dda5d0f90ca5a00a9569d110908046ae4425840e (patch) | |
tree | 5ada7a883b1c8050400cf610a4a0717209842f37 /user-manual.html | |
parent | 9f1a8e9ea774303ce10a23c0db10066388b7a0c6 (diff) | |
download | git-htmldocs-dda5d0f90ca5a00a9569d110908046ae4425840e.tar.gz |
Autogenerated HTML docs for v2.11.0-453-g787f7
Diffstat (limited to 'user-manual.html')
-rw-r--r-- | user-manual.html | 232 |
1 files changed, 116 insertions, 116 deletions
diff --git a/user-manual.html b/user-manual.html index c5ca4a43f..c752d2542 100644 --- a/user-manual.html +++ b/user-manual.html @@ -1,15 +1,15 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Git User Manual</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div lang="en" class="article"><div class="titlepage"><div><div><h2 class="title"><a name="idp51423728"></a>Git User Manual</h2></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#repositories-and-branches">Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#how-to-get-a-git-repository">How to get a Git repository</a></span></dt><dt><span class="section"><a href="#how-to-check-out">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#understanding-commits">Understanding History: Commits</a></span></dt><dt><span class="section"><a href="#manipulating-branches">Manipulating branches</a></span></dt><dt><span class="section"><a href="#detached-head">Examining an old version without creating a new branch</a></span></dt><dt><span class="section"><a href="#examining-remote-branches">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="#fetching-branches">Fetching branches from other repositories</a></span></dt></dl></dd><dt><span class="section"><a href="#exploring-git-history">Exploring Git history</a></span></dt><dd><dl><dt><span class="section"><a href="#using-bisect">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#naming-commits">Naming commits</a></span></dt><dt><span class="section"><a href="#creating-tags">Creating tags</a></span></dt><dt><span class="section"><a href="#browsing-revisions">Browsing revisions</a></span></dt><dt><span class="section"><a href="#generating-diffs">Generating diffs</a></span></dt><dt><span class="section"><a href="#viewing-old-file-versions">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#history-examples">Examples</a></span></dt></dl></dd><dt><span class="section"><a href="#Developing-With-git">Developing with Git</a></span></dt><dd><dl><dt><span class="section"><a href="#telling-git-your-name">Telling Git your name</a></span></dt><dt><span class="section"><a href="#creating-a-new-repository">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="#creating-good-commit-messages">Creating good commit messages</a></span></dt><dt><span class="section"><a href="#ignoring-files">Ignoring files</a></span></dt><dt><span class="section"><a href="#how-to-merge">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="#fast-forwards">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#fixing-mistakes">Fixing mistakes</a></span></dt><dt><span class="section"><a href="#ensuring-good-performance">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#ensuring-reliability">Ensuring reliability</a></span></dt></dl></dd><dt><span class="section"><a href="#sharing-development">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="#submitting-patches">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#importing-patches">Importing patches to a project</a></span></dt><dt><span class="section"><a href="#public-repositories">Public Git repositories</a></span></dt><dt><span class="section"><a href="#how-to-get-a-git-repository-with-minimal-history">How to get a Git repository with minimal history</a></span></dt><dt><span class="section"><a href="#sharing-development-examples">Examples</a></span></dt></dl></dd><dt><span class="section"><a href="#cleaning-up-history">Rewriting history and maintaining patch series</a></span></dt><dd><dl><dt><span class="section"><a href="#patch-series">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#using-git-rebase">Keeping a patch series up to date using git rebase</a></span></dt><dt><span class="section"><a href="#rewriting-one-commit">Rewriting a single commit</a></span></dt><dt><span class="section"><a href="#reordering-patch-series">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#interactive-rebase">Using interactive rebases</a></span></dt><dt><span class="section"><a href="#patch-series-tools">Other tools</a></span></dt><dt><span class="section"><a href="#problems-With-rewriting-history">Problems with rewriting history</a></span></dt><dt><span class="section"><a href="#bisect-merges">Why bisecting merge commits can be harder than bisecting linear history</a></span></dt></dl></dd><dt><span class="section"><a href="#advanced-branch-management">Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#fetching-individual-branches">Fetching individual branches</a></span></dt><dt><span class="section"><a href="#fetch-fast-forwards">git fetch and fast-forwards</a></span></dt><dt><span class="section"><a href="#forcing-fetch">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#remote-branch-configuration">Configuring remote-tracking branches</a></span></dt></dl></dd><dt><span class="section"><a href="#git-concepts">Git concepts</a></span></dt><dd><dl><dt><span class="section"><a href="#the-object-database">The Object Database</a></span></dt><dt><span class="section"><a href="#the-index">The index</a></span></dt></dl></dd><dt><span class="section"><a href="#submodules">Submodules</a></span></dt><dd><dl><dt><span class="section"><a href="#_pitfalls_with_submodules">Pitfalls with submodules</a></span></dt></dl></dd><dt><span class="section"><a href="#low-level-operations">Low-level Git operations</a></span></dt><dd><dl><dt><span class="section"><a href="#object-manipulation">Object access and manipulation</a></span></dt><dt><span class="section"><a href="#the-workflow">The Workflow</a></span></dt><dt><span class="section"><a href="#examining-the-data">Examining the data</a></span></dt><dt><span class="section"><a href="#merging-multiple-trees">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#merging-multiple-trees-2">Merging multiple trees, continued</a></span></dt></dl></dd><dt><span class="section"><a href="#hacking-git">Hacking Git</a></span></dt><dd><dl><dt><span class="section"><a href="#object-details">Object storage format</a></span></dt><dt><span class="section"><a href="#birdview-on-the-source-code">A birds-eye view of Git’s source code</a></span></dt></dl></dd><dt><span class="section"><a href="#glossary">Git Glossary</a></span></dt><dt><span class="appendix"><a href="#git-quick-start">A. Git Quick Reference</a></span></dt><dd><dl><dt><span class="section"><a href="#quick-creating-a-new-repository">Creating a new repository</a></span></dt><dt><span class="section"><a href="#managing-branches">Managing branches</a></span></dt><dt><span class="section"><a href="#exploring-history">Exploring history</a></span></dt><dt><span class="section"><a href="#making-changes">Making changes</a></span></dt><dt><span class="section"><a href="#merging">Merging</a></span></dt><dt><span class="section"><a href="#sharing-your-changes">Sharing your changes</a></span></dt><dt><span class="section"><a href="#repository-maintenance">Repository maintenance</a></span></dt></dl></dd><dt><span class="appendix"><a href="#todo">B. Notes and todo list for this manual</a></span></dt></dl></div><p>Git is a fast distributed revision control system.</p><p>This manual is designed to be readable by someone with basic UNIX -command-line skills, but no previous knowledge of Git.</p><p><a class="xref" href="#repositories-and-branches" title="Repositories and Branches">the section called “Repositories and Branches”</a> and <a class="xref" href="#exploring-git-history" title="Exploring Git history">the section called “Exploring Git history”</a> explain how +<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Git User Manual</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="idp49194000"></a>Git User Manual</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="preface"><a href="#idp49195248"></a></span></dt><dt><span class="chapter"><a href="#repositories-and-branches">1. Repositories and Branches</a></span></dt><dd><dl><dt><span class="section"><a href="#how-to-get-a-git-repository">How to get a Git repository</a></span></dt><dt><span class="section"><a href="#how-to-check-out">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#understanding-commits">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#understanding-reachability">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#history-diagrams">Understanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#what-is-a-branch">Understanding history: What is a branch?</a></span></dt></dl></dd><dt><span class="section"><a href="#manipulating-branches">Manipulating branches</a></span></dt><dt><span class="section"><a href="#detached-head">Examining an old version without creating a new branch</a></span></dt><dt><span class="section"><a href="#examining-remote-branches">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="#fetching-branches">Fetching branches from other repositories</a></span></dt></dl></dd><dt><span class="chapter"><a href="#exploring-git-history">2. Exploring Git history</a></span></dt><dd><dl><dt><span class="section"><a href="#using-bisect">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#naming-commits">Naming commits</a></span></dt><dt><span class="section"><a href="#creating-tags">Creating tags</a></span></dt><dt><span class="section"><a href="#browsing-revisions">Browsing revisions</a></span></dt><dt><span class="section"><a href="#generating-diffs">Generating diffs</a></span></dt><dt><span class="section"><a href="#viewing-old-file-versions">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#history-examples">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#counting-commits-on-a-branch">Counting the number of commits on a branch</a></span></dt><dt><span class="section"><a href="#checking-for-equal-branches">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#finding-tagged-descendants">Find first tagged version including a given fix</a></span></dt><dt><span class="section"><a href="#showing-commits-unique-to-a-branch">Showing commits unique to a given branch</a></span></dt><dt><span class="section"><a href="#making-a-release">Creating a changelog and tarball for a software release</a></span></dt><dt><span class="section"><a href="#Finding-commits-With-given-Content">Finding commits referencing a file with given content</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#Developing-With-git">3. Developing with Git</a></span></dt><dd><dl><dt><span class="section"><a href="#telling-git-your-name">Telling Git your name</a></span></dt><dt><span class="section"><a href="#creating-a-new-repository">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="#creating-good-commit-messages">Creating good commit messages</a></span></dt><dt><span class="section"><a href="#ignoring-files">Ignoring files</a></span></dt><dt><span class="section"><a href="#how-to-merge">How to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dd><dl><dt><span class="section"><a href="#conflict-resolution">Getting conflict-resolution help during a merge</a></span></dt></dl></dd><dt><span class="section"><a href="#undoing-a-merge">Undoing a merge</a></span></dt><dt><span class="section"><a href="#fast-forwards">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#fixing-mistakes">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#reverting-a-commit">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#fixing-a-mistake-by-rewriting-history">Fixing a mistake by rewriting history</a></span></dt><dt><span class="section"><a href="#checkout-of-path">Checking out an old version of a file</a></span></dt><dt><span class="section"><a href="#interrupted-work">Temporarily setting aside work in progress</a></span></dt></dl></dd><dt><span class="section"><a href="#ensuring-good-performance">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#ensuring-reliability">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#checking-for-corruption">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#recovering-lost-changes">Recovering lost changes</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#sharing-development">4. 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="#submitting-patches">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#importing-patches">Importing patches to a project</a></span></dt><dt><span class="section"><a href="#public-repositories">Public Git repositories</a></span></dt><dd><dl><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-git">Exporting a Git repository via the Git protocol</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="#pushing-changes-to-a-public-repository">Pushing changes to a public repository</a></span></dt><dt><span class="section"><a href="#forcing-push">What to do when a push fails</a></span></dt><dt><span class="section"><a href="#setting-up-a-shared-repository">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#setting-up-gitweb">Allowing web browsing of a repository</a></span></dt></dl></dd><dt><span class="section"><a href="#how-to-get-a-git-repository-with-minimal-history">How to get a Git repository with minimal history</a></span></dt><dt><span class="section"><a href="#sharing-development-examples">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#maintaining-topic-branches">Maintaining topic branches for a Linux subsystem maintainer</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#cleaning-up-history">5. Rewriting history and maintaining patch series</a></span></dt><dd><dl><dt><span class="section"><a href="#patch-series">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#using-git-rebase">Keeping a patch series up to date using git rebase</a></span></dt><dt><span class="section"><a href="#rewriting-one-commit">Rewriting a single commit</a></span></dt><dt><span class="section"><a href="#reordering-patch-series">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#interactive-rebase">Using interactive rebases</a></span></dt><dt><span class="section"><a href="#patch-series-tools">Other tools</a></span></dt><dt><span class="section"><a href="#problems-With-rewriting-history">Problems with rewriting history</a></span></dt><dt><span class="section"><a href="#bisect-merges">Why bisecting merge commits can be harder than bisecting linear history</a></span></dt></dl></dd><dt><span class="chapter"><a href="#advanced-branch-management">6. Advanced branch management</a></span></dt><dd><dl><dt><span class="section"><a href="#fetching-individual-branches">Fetching individual branches</a></span></dt><dt><span class="section"><a href="#fetch-fast-forwards">git fetch and fast-forwards</a></span></dt><dt><span class="section"><a href="#forcing-fetch">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#remote-branch-configuration">Configuring remote-tracking branches</a></span></dt></dl></dd><dt><span class="chapter"><a href="#git-concepts">7. Git concepts</a></span></dt><dd><dl><dt><span class="section"><a href="#the-object-database">The Object Database</a></span></dt><dd><dl><dt><span class="section"><a href="#commit-object">Commit Object</a></span></dt><dt><span class="section"><a href="#tree-object">Tree Object</a></span></dt><dt><span class="section"><a href="#blob-object">Blob Object</a></span></dt><dt><span class="section"><a href="#trust">Trust</a></span></dt><dt><span class="section"><a href="#tag-object">Tag Object</a></span></dt><dt><span class="section"><a href="#pack-files">How Git stores objects efficiently: pack files</a></span></dt><dt><span class="section"><a href="#dangling-objects">Dangling objects</a></span></dt><dt><span class="section"><a href="#recovering-from-repository-corruption">Recovering from repository corruption</a></span></dt></dl></dd><dt><span class="section"><a href="#the-index">The index</a></span></dt></dl></dd><dt><span class="chapter"><a href="#submodules">8. Submodules</a></span></dt><dd><dl><dt><span class="section"><a href="#_pitfalls_with_submodules">Pitfalls with submodules</a></span></dt></dl></dd><dt><span class="chapter"><a href="#low-level-operations">9. Low-level Git operations</a></span></dt><dd><dl><dt><span class="section"><a href="#object-manipulation">Object access and manipulation</a></span></dt><dt><span class="section"><a href="#the-workflow">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#working-directory-to-index">working directory → index</a></span></dt><dt><span class="section"><a href="#index-to-object-database">index → object database</a></span></dt><dt><span class="section"><a href="#object-database-to-index">object database → index</a></span></dt><dt><span class="section"><a href="#index-to-working-directory">index → working directory</a></span></dt><dt><span class="section"><a href="#tying-it-all-together">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#examining-the-data">Examining the data</a></span></dt><dt><span class="section"><a href="#merging-multiple-trees">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#merging-multiple-trees-2">Merging multiple trees, continued</a></span></dt></dl></dd><dt><span class="chapter"><a href="#hacking-git">10. Hacking Git</a></span></dt><dd><dl><dt><span class="section"><a href="#object-details">Object storage format</a></span></dt><dt><span class="section"><a href="#birdview-on-the-source-code">A birds-eye view of Git’s source code</a></span></dt></dl></dd><dt><span class="chapter"><a href="#glossary">11. Git Glossary</a></span></dt><dd><dl><dt><span class="section"><a href="#git-explained">Git explained</a></span></dt></dl></dd><dt><span class="appendix"><a href="#git-quick-start">A. Git Quick Reference</a></span></dt><dd><dl><dt><span class="section"><a href="#quick-creating-a-new-repository">Creating a new repository</a></span></dt><dt><span class="section"><a href="#managing-branches">Managing branches</a></span></dt><dt><span class="section"><a href="#exploring-history">Exploring history</a></span></dt><dt><span class="section"><a href="#making-changes">Making changes</a></span></dt><dt><span class="section"><a href="#merging">Merging</a></span></dt><dt><span class="section"><a href="#sharing-your-changes">Sharing your changes</a></span></dt><dt><span class="section"><a href="#repository-maintenance">Repository maintenance</a></span></dt></dl></dd><dt><span class="appendix"><a href="#todo">B. Notes and todo list for this manual</a></span></dt><dd><dl><dt><span class="section"><a href="#todo-list">Todo list</a></span></dt></dl></dd></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a name="idp49195248"></a></h1></div></div></div><p>Git is a fast distributed revision control system.</p><p>This manual is designed to be readable by someone with basic UNIX +command-line skills, but no previous knowledge of Git.</p><p><a class="xref" href="#repositories-and-branches" title="Chapter 1. Repositories and Branches">Chapter 1, <i>Repositories and Branches</i></a> and <a class="xref" href="#exploring-git-history" title="Chapter 2. Exploring Git history">Chapter 2, <i>Exploring Git history</i></a> explain how to fetch and study a project using git—read these chapters to learn how to build and test a particular version of a software project, search for regressions, and so on.</p><p>People needing to do actual development will also want to read -<a class="xref" href="#Developing-With-git" title="Developing with Git">the section called “Developing with Git”</a> and <a class="xref" href="#sharing-development" title="Sharing development with others">the section called “Sharing development with others”</a>.</p><p>Further chapters cover more specialized topics.</p><p>Comprehensive reference documentation is available through the man +<a class="xref" href="#Developing-With-git" title="Chapter 3. Developing with Git">Chapter 3, <i>Developing with Git</i></a> and <a class="xref" href="#sharing-development" title="Chapter 4. Sharing development with others">Chapter 4, <i>Sharing development with others</i></a>.</p><p>Further chapters cover more specialized topics.</p><p>Comprehensive reference documentation is available through the man pages, or <a class="ulink" href="git-help.html" target="_top">git-help(1)</a> command. For example, for the command <code class="literal">git clone <repo></code>, you can either use:</p><pre class="literallayout">$ man git-clone</pre><p>or:</p><pre class="literallayout">$ git help clone</pre><p>With the latter, you can use the manual viewer of your choice; see -<a class="ulink" href="git-help.html" target="_top">git-help(1)</a> for more information.</p><p>See also <a class="xref" href="#git-quick-start" title="A. Git Quick Reference">Appendix A, <i>Git Quick Reference</i></a> for a brief overview of Git commands, -without any explanation.</p><p>Finally, see <a class="xref" href="#todo" title="B. Notes and todo list for this manual">Appendix B, <i>Notes and todo list for this manual</i></a> for ways that you can help make this manual more -complete.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="repositories-and-branches"></a>Repositories and Branches</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="how-to-get-a-git-repository"></a>How to get a Git repository</h3></div></div></div><p>It will be useful to have a Git repository to experiment with as you +<a class="ulink" href="git-help.html" target="_top">git-help(1)</a> for more information.</p><p>See also <a class="xref" href="#git-quick-start" title="Appendix A. Git Quick Reference">Appendix A, <i>Git Quick Reference</i></a> for a brief overview of Git commands, +without any explanation.</p><p>Finally, see <a class="xref" href="#todo" title="Appendix B. Notes and todo list for this manual">Appendix B, <i>Notes and todo list for this manual</i></a> for ways that you can help make this manual more +complete.</p></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="repositories-and-branches"></a>Chapter 1. Repositories and Branches</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#how-to-get-a-git-repository">How to get a Git repository</a></span></dt><dt><span class="section"><a href="#how-to-check-out">How to check out a different version of a project</a></span></dt><dt><span class="section"><a href="#understanding-commits">Understanding History: Commits</a></span></dt><dd><dl><dt><span class="section"><a href="#understanding-reachability">Understanding history: commits, parents, and reachability</a></span></dt><dt><span class="section"><a href="#history-diagrams">Understanding history: History diagrams</a></span></dt><dt><span class="section"><a href="#what-is-a-branch">Understanding history: What is a branch?</a></span></dt></dl></dd><dt><span class="section"><a href="#manipulating-branches">Manipulating branches</a></span></dt><dt><span class="section"><a href="#detached-head">Examining an old version without creating a new branch</a></span></dt><dt><span class="section"><a href="#examining-remote-branches">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="#fetching-branches">Fetching branches from other repositories</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="how-to-get-a-git-repository"></a>How to get a Git repository</h2></div></div></div><p>It will be useful to have a Git repository to experiment with as you read this manual.</p><p>The best way to get one is by using the <a class="ulink" href="git-clone.html" target="_top">git-clone(1)</a> command to download a copy of an existing repository. If you don’t already have a project in mind, here are some interesting examples:</p><pre class="literallayout"> # Git itself (approx. 40MB download): @@ -21,7 +21,7 @@ will only need to clone once.</p><p>The clone command creates a new directory na directory, you will see that it contains a copy of the project files, called the <a class="link" href="#def_working_tree">working tree</a>, together with a special top-level directory named <code class="literal">.git</code>, which contains all the information -about the history of the project.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="how-to-check-out"></a>How to check out a different version of a project</h3></div></div></div><p>Git is best thought of as a tool for storing the history of a collection +about the history of the project.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="how-to-check-out"></a>How to check out a different version of a project</h2></div></div></div><p>Git is best thought of as a tool for storing the history of a collection of files. It stores the history as a compressed collection of interrelated snapshots of the project’s contents. In Git each such version is called a <a class="link" href="#def_commit">commit</a>.</p><p>Those snapshots aren’t necessarily all arranged in a single line from @@ -55,7 +55,7 @@ branches, with an asterisk marking the currently checked-out branch:</p><pre cla the current branch to point at v2.6.17 instead, with</p><pre class="literallayout">$ git reset --hard v2.6.17</pre><p>Note that if the current branch head was your only reference to a particular point in history, then resetting that branch may leave you with no way to find the history it used to point to; so use this command -carefully.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="understanding-commits"></a>Understanding History: Commits</h3></div></div></div><p>Every change in the history of a project is represented by a commit. +carefully.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="understanding-commits"></a>Understanding History: Commits</h2></div></div></div><p>Every change in the history of a project is represented by a commit. The <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> command shows the most recent commit on the current branch:</p><pre class="literallayout">$ git show commit 17cf781661e6d38f737f15f53ab552f1e95960d7 @@ -88,9 +88,9 @@ example in email), then you are guaranteed that name will refer to the same commit in their repository that it does in yours (assuming their repository has that commit at all). Since the object name is computed as a hash over the contents of the commit, you are guaranteed that the commit can never change -without its name also changing.</p><p>In fact, in <a class="xref" href="#git-concepts" title="Git concepts">the section called “Git concepts”</a> we shall see that everything stored in Git +without its name also changing.</p><p>In fact, in <a class="xref" href="#git-concepts" title="Chapter 7. Git concepts">Chapter 7, <i>Git concepts</i></a> we shall see that everything stored in Git history, including file data and directory contents, is stored in an object -with a name that is a hash of its contents.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="understanding-reachability"></a>Understanding history: commits, parents, and reachability</h4></div></div></div><p>Every commit (except the very first commit in a project) also has a +with a name that is a hash of its contents.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="understanding-reachability"></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 beginning of the project.</p><p>However, the commits do not form a simple list; Git allows lines of @@ -103,20 +103,20 @@ command; running gitk now on a Git repository and looking for merge commits will help understand how Git organizes history.</p><p>In the following, we say that commit X is "reachable" from commit Y if commit X is an ancestor of commit Y. Equivalently, you could say that Y is a descendant of X, or that there is a chain of parents -leading from commit Y to commit X.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="history-diagrams"></a>Understanding history: History diagrams</h4></div></div></div><p>We will sometimes represent Git history using diagrams like the one +leading from commit Y to commit X.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="history-diagrams"></a>Understanding history: History diagrams</h3></div></div></div><p>We will sometimes represent Git history using diagrams like the one below. Commits are shown as "o", and the links between them with lines drawn with - / and \. Time goes left to right:</p><pre class="literallayout"> o--o--o <-- Branch A / o--o--o <-- master \ o--o--o <-- Branch B</pre><p>If we need to talk about a particular commit, the character "o" may -be replaced with another letter or number.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="what-is-a-branch"></a>Understanding history: What is a branch?</h4></div></div></div><p>When we need to be precise, we will use the word "branch" to mean a line +be replaced with another letter or number.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="what-is-a-branch"></a>Understanding history: What is a branch?</h3></div></div></div><p>When we need to be precise, we will use the word "branch" to mean a line of development, and "branch head" (or just "head") to mean a reference to the most recent commit on a branch. In the example above, the branch head named "A" is a pointer to one particular commit, but we refer to the line of three commits leading up to that point as all being part of "branch A".</p><p>However, when no confusion will result, we often just use the term -"branch" both for branches and for branch heads.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="manipulating-branches"></a>Manipulating branches</h3></div></div></div><p>Creating, deleting, and modifying branches is quick and easy; here’s +"branch" both for branches and for branch heads.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="manipulating-branches"></a>Manipulating branches</h2></div></div></div><p>Creating, deleting, and modifying branches is quick and easy; here’s a summary of the commands:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"> <code class="literal">git branch</code> </span></dt><dd> @@ -155,7 +155,7 @@ a summary of the commands:</p><div class="variablelist"><dl class="variablelist" </dd></dl></div><p>The special symbol "HEAD" can always be used to refer to the current branch. In fact, Git uses a file named <code class="literal">HEAD</code> in the <code class="literal">.git</code> directory to remember which branch is current:</p><pre class="literallayout">$ cat .git/HEAD -ref: refs/heads/master</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="detached-head"></a>Examining an old version without creating a new branch</h3></div></div></div><p>The <code class="literal">git checkout</code> command normally expects a branch head, but will also +ref: refs/heads/master</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="detached-head"></a>Examining an old version without creating a new branch</h2></div></div></div><p>The <code class="literal">git checkout</code> command normally expects a branch head, but will also accept an arbitrary commit; for example, you can check out the commit referenced by a tag:</p><pre class="literallayout">$ git checkout v2.6.17 Note: checking out 'v2.6.17'. @@ -176,7 +176,7 @@ $ git branch * (detached from v2.6.17) master</pre><p>In this case we say that the HEAD is "detached".</p><p>This is an easy way to check out a particular version without having to make up a name for the new branch. You can still create a new branch -(or tag) for this version later if you decide to.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="examining-remote-branches"></a>Examining branches from a remote repository</h3></div></div></div><p>The "master" branch that was created at the time you cloned is a copy +(or tag) for this version later if you decide to.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="examining-remote-branches"></a>Examining branches from a remote repository</h2></div></div></div><p>The "master" branch that was created at the time you cloned is a copy of the HEAD in the repository that you cloned from. That repository may also have had other branches, though, and your local repository keeps branches which track each of those remote branches, called @@ -197,7 +197,7 @@ be updated by <code class="literal">git fetch</code> (hence <code class="literal <a class="xref" href="#Updating-a-repository-With-git-fetch" title="Updating a repository with git fetch">the section called “Updating a repository with git fetch”</a> for details.</p><p>You might want to build on one of these remote-tracking branches on a branch of your own, just as you would for a tag:</p><pre class="literallayout">$ git checkout -b my-todo-copy origin/todo</pre><p>You can also check out <code class="literal">origin/todo</code> directly to examine it or write a one-off patch. See <a class="link" href="#detached-head" title="Examining an old version without creating a new branch">detached head</a>.</p><p>Note that the name "origin" is just the name that Git uses by default -to refer to the repository that you cloned from.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="how-git-stores-references"></a>Naming branches, tags, and other references</h3></div></div></div><p>Branches, remote-tracking branches, and tags are all references to +to refer to the repository that you cloned from.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="how-git-stores-references"></a>Naming branches, tags, and other references</h2></div></div></div><p>Branches, remote-tracking branches, and tags are all references to commits. All references are named with a slash-separated path name starting with <code class="literal">refs</code>; the names we’ve been using so far are actually shorthand:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> @@ -215,11 +215,11 @@ to just using the name of that repository. So, for example, "origin" is usually a shortcut for the HEAD branch in the repository "origin".</p><p>For the complete list of paths which Git checks for references, and the order it uses to decide which to choose when there are multiple references with the same shorthand name, see the "SPECIFYING -REVISIONS" section of <a class="ulink" href="gitrevisions.html" target="_top">gitrevisions(7)</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="Updating-a-repository-With-git-fetch"></a>Updating a repository with git fetch</h3></div></div></div><p>After you clone a repository and commit a few changes of your own, you +REVISIONS" section of <a class="ulink" href="gitrevisions.html" target="_top">gitrevisions(7)</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Updating-a-repository-With-git-fetch"></a>Updating a repository with git fetch</h2></div></div></div><p>After you clone a repository and commit a few changes of your own, you may wish to check the original repository for updates.</p><p>The <code class="literal">git-fetch</code> command, with no arguments, will update all of the remote-tracking branches to the latest version found in the original repository. It will not touch any of your own branches—not even the -"master" branch that was created for you on clone.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="fetching-branches"></a>Fetching branches from other repositories</h3></div></div></div><p>You can also track branches from repositories other than the one you +"master" branch that was created for you on clone.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="fetching-branches"></a>Fetching branches from other repositories</h2></div></div></div><p>You can also track branches from repositories other than the one you cloned from, using <a class="ulink" href="git-remote.html" target="_top">git-remote(1)</a>:</p><pre class="literallayout">$ git remote add staging git://git.kernel.org/.../gregkh/staging.git $ git fetch staging ... @@ -242,12 +242,12 @@ a new stanza:</p><pre class="literallayout">$ cat .git/config ...</pre><p>This is what causes Git to track the remote’s branches; you may modify or delete these configuration options by editing <code class="literal">.git/config</code> with a text editor. (See the "CONFIGURATION FILE" section of -<a class="ulink" href="git-config.html" target="_top">git-config(1)</a> for details.)</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="exploring-git-history"></a>Exploring Git history</h2></div></div></div><p>Git is best thought of as a tool for storing the history of a +<a class="ulink" href="git-config.html" target="_top">git-config(1)</a> for details.)</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="exploring-git-history"></a>Chapter 2. Exploring Git history</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#using-bisect">How to use bisect to find a regression</a></span></dt><dt><span class="section"><a href="#naming-commits">Naming commits</a></span></dt><dt><span class="section"><a href="#creating-tags">Creating tags</a></span></dt><dt><span class="section"><a href="#browsing-revisions">Browsing revisions</a></span></dt><dt><span class="section"><a href="#generating-diffs">Generating diffs</a></span></dt><dt><span class="section"><a href="#viewing-old-file-versions">Viewing old file versions</a></span></dt><dt><span class="section"><a href="#history-examples">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#counting-commits-on-a-branch">Counting the number of commits on a branch</a></span></dt><dt><span class="section"><a href="#checking-for-equal-branches">Check whether two branches point at the same history</a></span></dt><dt><span class="section"><a href="#finding-tagged-descendants">Find first tagged version including a given fix</a></span></dt><dt><span class="section"><a href="#showing-commits-unique-to-a-branch">Showing commits unique to a given branch</a></span></dt><dt><span class="section"><a href="#making-a-release">Creating a changelog and tarball for a software release</a></span></dt><dt><span class="section"><a href="#Finding-commits-With-given-Content">Finding commits referencing a file with given content</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 hierarchy, 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 that is useful for finding the -commit that introduced a bug into a project.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="using-bisect"></a>How to use bisect to find a regression</h3></div></div></div><p>Suppose version 2.6.18 of your project worked, but the version at +commit that introduced a bug into a project.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="using-bisect"></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 history to find the particular commit that caused the problem. The @@ -280,7 +280,7 @@ the current commit:</p><pre class="literallayout">$ git bisect skip</pre><p>In t bad one between some first skipped commits and a later bad commit.</p><p>There are also ways to automate the bisecting process if you have a test script that can tell a good from a bad commit. See <a class="ulink" href="git-bisect.html" target="_top">git-bisect(1)</a> for more information about this and other <code class="literal">git -bisect</code> features.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="naming-commits"></a>Naming commits</h3></div></div></div><p>We have seen several ways of naming commits already:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> +bisect</code> features.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="naming-commits"></a>Naming commits</h2></div></div></div><p>We have seen several ways of naming commits already:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 40-hexdigit object name </li><li class="listitem"> branch name: refers to the commit at the head of the given @@ -310,11 +310,11 @@ which refers to the other branch that we’re merging in to the current branch.</p><p>The <a class="ulink" href="git-rev-parse.html" target="_top">git-rev-parse(1)</a> command is a low-level command that is occasionally useful for translating some name for a commit to the object name for that commit:</p><pre class="literallayout">$ git rev-parse origin -e05db0fd4f31dde7005f075a84f96b360d05984b</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="creating-tags"></a>Creating tags</h3></div></div></div><p>We can also create a tag to refer to a particular commit; after +e05db0fd4f31dde7005f075a84f96b360d05984b</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="creating-tags"></a>Creating tags</h2></div></div></div><p>We can also create a tag to refer to a particular commit; after running</p><pre class="literallayout">$ git tag stable-1 1b2e1d63ff</pre><p>You can use <code class="literal">stable-1</code> to refer to the commit 1b2e1d63ff.</p><p>This creates a "lightweight" tag. If you would also like to include a comment with the tag, and possibly sign it cryptographically, then you should create a tag object instead; see the <a class="ulink" href="git-tag.html" target="_top">git-tag(1)</a> man page -for details.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="browsing-revisions"></a>Browsing revisions</h3></div></div></div><p>The <a class="ulink" href="git-log.html" target="_top">git-log(1)</a> command can show lists of commits. On its +for details.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="browsing-revisions"></a>Browsing revisions</h2></div></div></div><p>The <a class="ulink" href="git-log.html" target="_top">git-log(1)</a> command can show lists of commits. On its own, it shows all commits reachable from the parent commit; but you can also make more specific requests:</p><pre class="literallayout">$ git log v2.5.. # commits since (not reachable from) v2.5 $ git log test..master # commits reachable from master but not test @@ -330,19 +330,19 @@ commits since v2.5 which touch the <code class="literal">Makefile</code> or any display options.</p><p>Note that git log starts with the most recent commit and works backwards through the parents; however, since Git history can contain multiple independent lines of development, the particular order that -commits are listed in may be somewhat arbitrary.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="generating-diffs"></a>Generating diffs</h3></div></div></div><p>You can generate diffs between any two versions using +commits are listed in may be somewhat arbitrary.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="generating-diffs"></a>Generating diffs</h2></div></div></div><p>You can generate diffs between any two versions using <a class="ulink" href="git-diff.html" target="_top">git-diff(1)</a>:</p><pre class="literallayout">$ git diff master..test</pre><p>That will produce the diff between the tips of the two branches. If you’d prefer to find the diff from their common ancestor to test, you can use three dots instead of two:</p><pre class="literallayout">$ git diff master...test</pre><p>Sometimes what you want instead is a set of patches; for this you can use <a class="ulink" href="git-format-patch.html" target="_top">git-format-patch(1)</a>:</p><pre class="literallayout">$ git format-patch master..test</pre><p>will generate a file with a patch for each commit reachable from test -but not from master.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="viewing-old-file-versions"></a>Viewing old file versions</h3></div></div></div><p>You can always view an old version of a file by just checking out the +but not from master.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="viewing-old-file-versions"></a>Viewing old file versions</h2></div></div></div><p>You can always view an old version of a file by just checking out the correct revision first. But sometimes it is more convenient to be able to view an old version of a single file without checking anything out; this command does that:</p><pre class="literallayout">$ git show v2.5:fs/locks.c</pre><p>Before the colon may be anything that names a commit, and after it -may be any path to a file tracked by Git.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="history-examples"></a>Examples</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="counting-commits-on-a-branch"></a>Counting the number of commits on a branch</h4></div></div></div><p>Suppose you want to know how many commits you’ve made on <code class="literal">mybranch</code> +may be any path to a file tracked by Git.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="history-examples"></a>Examples</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="counting-commits-on-a-branch"></a>Counting the number of commits on a branch</h3></div></div></div><p>Suppose you want to know how many commits you’ve made on <code class="literal">mybranch</code> since it diverged from <code class="literal">origin</code>:</p><pre class="literallayout">$ git log --pretty=oneline origin..mybranch | wc -l</pre><p>Alternatively, you may often see this sort of thing done with the lower-level command <a class="ulink" href="git-rev-list.html" target="_top">git-rev-list(1)</a>, which just lists the SHA-1’s -of all the given commits:</p><pre class="literallayout">$ git rev-list origin..mybranch | wc -l</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="checking-for-equal-branches"></a>Check whether two branches point at the same history</h4></div></div></div><p>Suppose you want to check whether two branches point at the same point +of all the given commits:</p><pre class="literallayout">$ git rev-list origin..mybranch | wc -l</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="checking-for-equal-branches"></a>Check whether two branches point at the same history</h3></div></div></div><p>Suppose you want to check whether two branches point at the same point in history.</p><pre class="literallayout">$ git diff origin..master</pre><p>will tell you whether the contents of the project are the same at the two branches; in theory, however, it’s possible that the same project contents could have been arrived at by two different historical @@ -351,7 +351,7 @@ e05db0fd4f31dde7005f075a84f96b360d05984b $ git rev-list master e05db0fd4f31dde7005f075a84f96b360d05984b</pre><p>Or you could recall that the <code class="literal">...</code> operator selects all commits reachable from either one reference or the other but not -both; so</p><pre class="literallayout">$ git log origin...master</pre><p>will return no commits when the two branches are equal.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="finding-tagged-descendants"></a>Find first tagged version including a given fix</h4></div></div></div><p>Suppose you know that the commit e05db0fd fixed a certain problem. +both; so</p><pre class="literallayout">$ git log origin...master</pre><p>will return no commits when the two branches are equal.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="finding-tagged-descendants"></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 @@ -378,7 +378,7 @@ available ! [v1.5.0-rc2] GIT v1.5.0-rc2 ...</pre><p>then a line like</p><pre class="literallayout">+ ++ [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if available</pre><p>shows that e05db0fd is reachable from itself, from v1.5.0-rc1, -and from v1.5.0-rc2, and not from v1.5.0-rc0.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="showing-commits-unique-to-a-branch"></a>Showing commits unique to a given branch</h4></div></div></div><p>Suppose you would like to see all the commits reachable from the branch +and from v1.5.0-rc2, and not from v1.5.0-rc0.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="showing-commits-unique-to-a-branch"></a>Showing commits unique to a given branch</h3></div></div></div><p>Suppose you would like to see all the commits reachable from the branch head named <code class="literal">master</code> but not from any other head in your repository.</p><p>We can list all the heads in this repository with <a class="ulink" href="git-show-ref.html" target="_top">git-show-ref(1)</a>:</p><pre class="literallayout">$ git show-ref --heads bf62196b5e363d73353a9dcf094c59595f3153b7 refs/heads/core-tutorial @@ -394,7 +394,7 @@ refs/heads/tutorial-fixes</pre><p>And then we can ask to see all the commits rea but not from these other heads:</p><pre class="literallayout">$ gitk master --not $( git show-ref --heads | cut -d' ' -f2 | grep -v '^refs/heads/master' )</pre><p>Obviously, endless variations are possible; for example, to see all commits reachable from some head but not from any tag in the repository:</p><pre class="literallayout">$ gitk $( git show-ref --heads ) --not $( git show-ref --tags )</pre><p>(See <a class="ulink" href="gitrevisions.html" target="_top">gitrevisions(7)</a> for explanations of commit-selecting -syntax such as <code class="literal">--not</code>.)</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="making-a-release"></a>Creating a changelog and tarball for a software release</h4></div></div></div><p>The <a class="ulink" href="git-archive.html" target="_top">git-archive(1)</a> command can create a tar or zip archive from +syntax such as <code class="literal">--not</code>.)</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="making-a-release"></a>Creating a changelog and tarball for a software release</h3></div></div></div><p>The <a class="ulink" href="git-archive.html" target="_top">git-archive(1)</a> command can create a tar or zip archive from any version of a project; for example:</p><pre class="literallayout">$ git archive -o latest.tar.gz --prefix=project/ HEAD</pre><p>will use HEAD to produce a gzipped tar archive in which each filename is preceded by <code class="literal">project/</code>. The output file format is inferred from the output file extension if possible, see <a class="ulink" href="git-archive.html" target="_top">git-archive(1)</a> for @@ -412,25 +412,25 @@ echo "git diff v$stable v$new | gzip -9 > ../patch-$new.gz" echo "git log --no-merges v$new ^v$last > ../ChangeLog-$new" echo "git shortlog --no-merges v$new ^v$last > ../ShortLog" echo "git diff --stat --summary -M v$last v$new > ../diffstat-$new"</pre><p>and then he just cut-and-pastes the output commands after verifying that -they look OK.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="Finding-commits-With-given-Content"></a>Finding commits referencing a file with given content</h4></div></div></div><p>Somebody hands you a copy of a file, and asks which commits modified a +they look OK.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="Finding-commits-With-given-Content"></a>Finding commits referencing a file with given content</h3></div></div></div><p>Somebody hands you a copy of a file, and asks which commits modified a file such that it contained the given content either before or after the commit. You can find out with this:</p><pre class="literallayout">$ git log --raw --abbrev=40 --pretty=oneline | grep -B 1 `git hash-object filename`</pre><p>Figuring out why this works is left as an exercise to the (advanced) student. The <a class="ulink" href="git-log.html" target="_top">git-log(1)</a>, <a class="ulink" href="git-diff-tree.html" target="_top">git-diff-tree(1)</a>, and -<a class="ulink" href="git-hash-object.html" target="_top">git-hash-object(1)</a> man pages may prove helpful.</p></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Developing-With-git"></a>Developing with Git</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="telling-git-your-name"></a>Telling Git your name</h3></div></div></div><p>Before creating any commits, you should introduce yourself to Git. +<a class="ulink" href="git-hash-object.html" target="_top">git-hash-object(1)</a> man pages may prove helpful.</p></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="Developing-With-git"></a>Chapter 3. Developing with Git</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#telling-git-your-name">Telling Git your name</a></span></dt><dt><span class="section"><a href="#creating-a-new-repository">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="#creating-good-commit-messages">Creating good commit messages</a></span></dt><dt><span class="section"><a href="#ignoring-files">Ignoring files</a></span></dt><dt><span class="section"><a href="#how-to-merge">How to merge</a></span></dt><dt><span class="section"><a href="#resolving-a-merge">Resolving a merge</a></span></dt><dd><dl><dt><span class="section"><a href="#conflict-resolution">Getting conflict-resolution help during a merge</a></span></dt></dl></dd><dt><span class="section"><a href="#undoing-a-merge">Undoing a merge</a></span></dt><dt><span class="section"><a href="#fast-forwards">Fast-forward merges</a></span></dt><dt><span class="section"><a href="#fixing-mistakes">Fixing mistakes</a></span></dt><dd><dl><dt><span class="section"><a href="#reverting-a-commit">Fixing a mistake with a new commit</a></span></dt><dt><span class="section"><a href="#fixing-a-mistake-by-rewriting-history">Fixing a mistake by rewriting history</a></span></dt><dt><span class="section"><a href="#checkout-of-path">Checking out an old version of a file</a></span></dt><dt><span class="section"><a href="#interrupted-work">Temporarily setting aside work in progress</a></span></dt></dl></dd><dt><span class="section"><a href="#ensuring-good-performance">Ensuring good performance</a></span></dt><dt><span class="section"><a href="#ensuring-reliability">Ensuring reliability</a></span></dt><dd><dl><dt><span class="section"><a href="#checking-for-corruption">Checking the repository for corruption</a></span></dt><dt><span class="section"><a href="#recovering-lost-changes">Recovering lost changes</a></span></dt></dl></dd></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="telling-git-your-name"></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 to use <a class="ulink" href="git-config.html" target="_top">git-config(1)</a>:</p><pre class="literallayout">$ git config --global user.name 'Your Name Comes Here' $ git config --global user.email 'you@yourdomain.example.com'</pre><p>Which will add the following to a file named <code class="literal">.gitconfig</code> in your home directory:</p><pre class="literallayout">[user] name = Your Name Comes Here email = you@yourdomain.example.com</pre><p>See the "CONFIGURATION FILE" section of <a class="ulink" href="git-config.html" target="_top">git-config(1)</a> for details on the configuration file. The file is plain text, so you can -also edit it with your favorite editor.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="creating-a-new-repository"></a>Creating a new repository</h3></div></div></div><p>Creating a new repository from scratch is very easy:</p><pre class="literallayout">$ mkdir project +also edit it with your favorite editor.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="creating-a-new-repository"></a>Creating a new repository</h2></div></div></div><p>Creating a new repository from scratch is very easy:</p><pre class="literallayout">$ mkdir project $ cd project $ git init</pre><p>If you have some initial content (say, a tarball):</p><pre class="literallayout">$ tar xzvf project.tar.gz $ cd project $ git init $ git add . # include everything below ./ in the first commit: -$ git commit</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="how-to-make-a-commit"></a>How to make a commit</h3></div></div></div><p>Creating a new commit takes three steps:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> +$ git commit</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="how-to-make-a-commit"></a>How to make a commit</h2></div></div></div><p>Creating a new commit takes three steps:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> Making some changes to the working directory using your favorite editor. </li><li class="listitem"> @@ -460,14 +460,14 @@ $ git diff HEAD # difference between HEAD and working tree; what $ git status # a brief per-file summary of the above.</pre><p>You can also use <a class="ulink" href="git-gui.html" target="_top">git-gui(1)</a> to create commits, view changes in the index and the working tree files, and individually select diff hunks for inclusion in the index (by right-clicking on the diff hunk and -choosing "Stage Hunk For Commit").</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="creating-good-commit-messages"></a>Creating good commit messages</h3></div></div></div><p>Though not required, it’s a good idea to begin the commit message +choosing "Stage Hunk For Commit").</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="creating-good-commit-messages"></a>Creating good commit messages</h2></div></div></div><p>Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git. For example, <a class="ulink" href="git-format-patch.html" target="_top">git-format-patch(1)</a> turns a commit into email, and it uses the title on the Subject line and the -rest of the commit in the body.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="ignoring-files"></a>Ignoring files</h3></div></div></div><p>A project will often generate files that you do <span class="emphasis"><em>not</em></span> want to track with Git. +rest of the commit in the body.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ignoring-files"></a>Ignoring files</h2></div></div></div><p>A project will often generate files that you do <span class="emphasis"><em>not</em></span> want to track with Git. This typically includes files generated by a build process or temporary backup files made by your editor. Of course, <span class="emphasis"><em>not</em></span> tracking files with Git is just a matter of <span class="emphasis"><em>not</em></span> calling <code class="literal">git add</code> on them. But it quickly becomes @@ -494,7 +494,7 @@ for other users who clone your repository.</p><p>If you wish the exclude pattern them in a file in your repository named <code class="literal">.git/info/exclude</code>, or in any file specified by the <code class="literal">core.excludesFile</code> configuration variable. Some Git commands can also take exclude patterns directly on the -command line. See <a class="ulink" href="gitignore.html" target="_top">gitignore(5)</a> for the details.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="how-to-merge"></a>How to merge</h3></div></div></div><p>You can rejoin two diverging branches of development using +command line. See <a class="ulink" href="gitignore.html" target="_top">gitignore(5)</a> for the details.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="how-to-merge"></a>How to merge</h2></div></div></div><p>You can rejoin two diverging branches of development using <a class="ulink" href="git-merge.html" target="_top">git-merge(1)</a>:</p><pre class="literallayout">$ git merge branchname</pre><p>merges the development in the branch <code class="literal">branchname</code> into the current branch.</p><p>A merge is made by combining the changes made in <code class="literal">branchname</code> and the changes made up to the latest commit in your current branch since @@ -519,7 +519,7 @@ you resolve the conflicts manually, you can update the index with the contents and run Git commit, as you normally would when creating a new file.</p><p>If you examine the resulting commit using gitk, you will see that it has two parents, one pointing to the top of the current branch, and -one to the top of the other branch.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="resolving-a-merge"></a>Resolving a merge</h3></div></div></div><p>When a merge isn’t resolved automatically, Git leaves the index and +one to the top of the other branch.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="resolving-a-merge"></a>Resolving a merge</h2></div></div></div><p>When a merge isn’t resolved automatically, Git leaves the index and the working tree in a special state that gives you all the information you need to help resolve the merge.</p><p>Files with conflicts are marked specially in the index, so until you resolve the problem and update the index, <a class="ulink" href="git-commit.html" target="_top">git-commit(1)</a> will @@ -534,7 +534,7 @@ $ git commit</pre><p>Note that the commit message will already be filled in for some information about the merge. Normally you can just use this default message unchanged, but you may add additional commentary of your own if desired.</p><p>The above is all you need to know to resolve a simple merge. But Git -also provides more information to help resolve conflicts:</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="conflict-resolution"></a>Getting conflict-resolution help during a merge</h4></div></div></div><p>All of the changes that Git was able to merge automatically are +also provides more information to help resolve conflicts:</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="conflict-resolution"></a>Getting conflict-resolution help during a merge</h3></div></div></div><p>All of the changes that Git was able to merge automatically are already added to the index file, so <a class="ulink" href="git-diff.html" target="_top">git-diff(1)</a> shows only the conflicts. It uses an unusual syntax:</p><pre class="literallayout">$ git diff diff --cc file.txt @@ -584,18 +584,18 @@ for merges:</p><pre class="literallayout">$ git log --merge $ gitk --merge</pre><p>These will display all commits which exist only on HEAD or on MERGE_HEAD, and which touch an unmerged file.</p><p>You may also use <a class="ulink" href="git-mergetool.html" target="_top">git-mergetool(1)</a>, which lets you merge the unmerged files using external tools such as Emacs or kdiff3.</p><p>Each time you resolve the conflicts in a file and update the index:</p><pre class="literallayout">$ git add file.txt</pre><p>the different stages of that file will be "collapsed", after which -<code class="literal">git diff</code> will (by default) no longer show diffs for that file.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="undoing-a-merge"></a>Undoing a merge</h3></div></div></div><p>If you get stuck and decide to just give up and throw the whole mess +<code class="literal">git diff</code> will (by default) no longer show diffs for that file.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="undoing-a-merge"></a>Undoing a merge</h2></div></div></div><p>If you get stuck and decide to just give up and throw the whole mess away, you can always return to the pre-merge state with</p><pre class="literallayout">$ git reset --hard HEAD</pre><p>Or, if you’ve already committed the merge that you want to throw away,</p><pre class="literallayout">$ git reset --hard ORIG_HEAD</pre><p>However, this last command can be dangerous in some cases—never throw away a commit you have already committed if that commit may itself have been merged into another branch, as doing so may confuse -further merges.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="fast-forwards"></a>Fast-forward merges</h3></div></div></div><p>There is one special case not mentioned above, which is treated +further merges.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="fast-forwards"></a>Fast-forward merges</h2></div></div></div><p>There is one special case not mentioned above, which is treated differently. Normally, a merge results in a merge commit, with two parents, one pointing at each of the two lines of development that were merged.</p><p>However, if the current branch is an ancestor of the other—so every commit present in the current branch is already contained in the other branch—then Git just performs a "fast-forward"; 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"><div class="titlepage"><div><div><h3 class="title"><a name="fixing-mistakes"></a>Fixing mistakes</h3></div></div></div><p>If you’ve messed up the working tree, but haven’t yet committed your +created.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="fixing-mistakes"></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><pre class="literallayout">$ git reset --hard HEAD</pre><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 class="orderedlist" type="1"><li class="listitem"> @@ -608,13 +608,13 @@ You can go back and modify the old commit. You should 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"><div class="titlepage"><div><div><h4 class="title"><a name="reverting-a-commit"></a>Fixing a mistake with a new commit</h4></div></div></div><p>Creating a new commit that reverts an earlier change is very easy; +</li></ol></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="reverting-a-commit"></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 class="ulink" 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><pre class="literallayout">$ git revert HEAD</pre><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><pre class="literallayout">$ git revert HEAD^</pre><p>In this case Git will attempt to undo the old change while leaving intact any changes made since then. If more recent changes overlap with the changes to be reverted, then you will be asked to fix -conflicts manually, just as in the case of <a class="link" href="#resolving-a-merge" title="Resolving a merge">resolving a merge</a>.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="fixing-a-mistake-by-rewriting-history"></a>Fixing a mistake by rewriting history</h4></div></div></div><p>If the problematic commit is the most recent commit, and you have not +conflicts manually, just as in the case of <a class="link" href="#resolving-a-merge" title="Resolving a merge">resolving a merge</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="fixing-a-mistake-by-rewriting-history"></a>Fixing a mistake by rewriting history</h3></div></div></div><p>If the problematic commit is the most recent commit, and you have not yet made that commit public, then you may just <a class="link" href="#undoing-a-merge" title="Undoing a merge">destroy it using <code class="literal">git reset</code></a>.</p><p>Alternatively, you can edit the working directory and update the index to fix your @@ -623,14 +623,14 @@ changes, giving you a chance to edit the old commit message first.</p><p>Again, been merged into another branch; use <a class="ulink" href="git-revert.html" target="_top">git-revert(1)</a> instead in that case.</p><p>It is also possible to replace commits further back in the history, but this is an advanced topic to be left for -<a class="link" href="#cleaning-up-history" title="Rewriting history and maintaining patch series">another chapter</a>.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="checkout-of-path"></a>Checking out an old version of a file</h4></div></div></div><p>In the process of undoing a previous bad change, you may find it +<a class="link" href="#cleaning-up-history" title="Chapter 5. Rewriting history and maintaining patch series">another chapter</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="checkout-of-path"></a>Checking out an old version of a file</h3></div></div></div><p>In the process of undoing a previous bad change, you may find it useful to check out an older version of a particular file using <a class="ulink" href="git-checkout.html" target="_top">git-checkout(1)</a>. We’ve used <code class="literal">git checkout</code> before to switch branches, but it has quite different behavior if it is given a path name: the command</p><pre class="literallayout">$ git checkout HEAD^ path/to/file</pre><p>replaces path/to/file by the contents it had in the commit HEAD^, and also updates the index to match. It does not change branches.</p><p>If you just want to look at an old version of the file, without modifying the working directory, you can do that with -<a class="ulink" href="git-show.html" target="_top">git-show(1)</a>:</p><pre class="literallayout">$ git show HEAD^:path/to/file</pre><p>which will display the given version of the file.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="interrupted-work"></a>Temporarily setting aside work in progress</h4></div></div></div><p>While you are in the middle of working on something complicated, you +<a class="ulink" href="git-show.html" target="_top">git-show(1)</a>:</p><pre class="literallayout">$ git show HEAD^:path/to/file</pre><p>which will display the given version of the file.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="interrupted-work"></a>Temporarily setting aside work in progress</h3></div></div></div><p>While you are in the middle of working on something complicated, you find an unrelated but obvious and trivial bug. You would like to fix it before continuing. You can use <a class="ulink" href="git-stash.html" target="_top">git-stash(1)</a> to save the current state of your work, and after fixing the bug (or, optionally after doing @@ -639,12 +639,12 @@ work-in-progress changes.</p><pre class="literallayout">$ git stash save "work i reset your working tree and the index to match the tip of your current branch. Then you can make your fix as usual.</p><pre class="literallayout">... edit and test ... $ git commit -a -m "blorpl: typofix"</pre><p>After that, you can go back to what you were working on with -<code class="literal">git stash pop</code>:</p><pre class="literallayout">$ git stash pop</pre></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="ensuring-good-performance"></a>Ensuring good performance</h3></div></div></div><p>On large repositories, Git depends on compression to keep the history +<code class="literal">git stash pop</code>:</p><pre class="literallayout">$ git stash pop</pre></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ensuring-good-performance"></a>Ensuring good performance</h2></div></div></div><p>On large repositories, Git depends on compression to keep the history information from taking up too much space on disk or in memory. Some Git commands may automatically run <a class="ulink" href="git-gc.html" target="_top">git-gc(1)</a>, so you don’t have to worry about running it manually. However, compressing a large repository may take a while, so you may want to call <code class="literal">gc</code> explicitly -to avoid automatic compression kicking in when it is not convenient.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="ensuring-reliability"></a>Ensuring reliability</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="checking-for-corruption"></a>Checking the repository for corruption</h4></div></div></div><p>The <a class="ulink" href="git-fsck.html" target="_top">git-fsck(1)</a> command runs a number of self-consistency checks +to avoid automatic compression kicking in when it is not convenient.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ensuring-reliability"></a>Ensuring reliability</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="checking-for-corruption"></a>Checking the repository for corruption</h3></div></div></div><p>The <a class="ulink" href="git-fsck.html" target="_top">git-fsck(1)</a> command runs a number of self-consistency checks on the repository, and reports on any problems. This may take some time.</p><pre class="literallayout">$ git fsck dangling commit 7281251ddd2a61e38657c827739c57015671a6b3 @@ -659,7 +659,7 @@ dangling tree b24c2473f1fd3d91352a624795be026d64c8841f that still exist in the repository but are no longer referenced by any of your branches, and can (and will) be removed after a while with <code class="literal">gc</code>. You can run <code class="literal">git fsck --no-dangling</code> to suppress these messages, and still -view real errors.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="recovering-lost-changes"></a>Recovering lost changes</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="reflogs"></a>Reflogs</h5></div></div></div><p>Say you modify a branch with <a class="link" href="#fixing-mistakes" title="Fixing mistakes"><code class="literal">git reset --hard</code></a>, +view real errors.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="recovering-lost-changes"></a>Recovering lost changes</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="reflogs"></a>Reflogs</h4></div></div></div><p>Say you modify a branch with <a class="link" href="#fixing-mistakes" title="Fixing mistakes"><code class="literal">git reset --hard</code></a>, 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 @@ -677,7 +677,7 @@ how to control this pruning, and see the "SPECIFYING REVISIONS" section of <a class="ulink" href="gitrevisions.html" target="_top">gitrevisions(7)</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"><div class="titlepage"><div><div><h5 class="title"><a name="dangling-object-recovery"></a>Examining dangling objects</h5></div></div></div><p>In some situations the reflog may not be able to save you. For example, +how the branches in your local repository have changed over time.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="dangling-object-recovery"></a>Examining dangling objects</h4></div></div></div><p>In some situations the reflog may not be able to save you. For example, suppose you delete a branch, then realize you need the history it contained. The reflog is also deleted; however, if you have not yet pruned the repository, then you may still be able to find the lost @@ -695,7 +695,7 @@ you get exactly the history reachable from that commit that is lost. "tip of the line" as being dangling, but there might be a whole deep and complex commit history that was dropped.)</p><p>If you decide you want the history back, you can always create a new reference pointing to it, for example, a new branch:</p><pre class="literallayout">$ git branch recovered-branch 7281251ddd</pre><p>Other types of dangling objects (blobs and trees) are also possible, and -dangling objects can arise in other situations.</p></div></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sharing-development"></a>Sharing development with others</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="getting-updates-With-git-pull"></a>Getting updates with git pull</h3></div></div></div><p>After you clone a repository and commit a few changes of your own, you +dangling objects can arise in other situations.</p></div></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="sharing-development"></a>Chapter 4. Sharing development with others</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><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="#submitting-patches">Submitting patches to a project</a></span></dt><dt><span class="section"><a href="#importing-patches">Importing patches to a project</a></span></dt><dt><span class="section"><a href="#public-repositories">Public Git repositories</a></span></dt><dd><dl><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-git">Exporting a Git repository via the Git protocol</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="#pushing-changes-to-a-public-repository">Pushing changes to a public repository</a></span></dt><dt><span class="section"><a href="#forcing-push">What to do when a push fails</a></span></dt><dt><span class="section"><a href="#setting-up-a-shared-repository">Setting up a shared repository</a></span></dt><dt><span class="section"><a href="#setting-up-gitweb">Allowing web browsing of a repository</a></span></dt></dl></dd><dt><span class="section"><a href="#how-to-get-a-git-repository-with-minimal-history">How to get a Git repository with minimal history</a></span></dt><dt><span class="section"><a href="#sharing-development-examples">Examples</a></span></dt><dd><dl><dt><span class="section"><a href="#maintaining-topic-branches">Maintaining topic branches for a Linux subsystem maintainer</a></span></dt></dl></dd></dl></div><div class="section"><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 commit 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 class="link" 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 class="ulink" href="git-fetch.html" target="_top">git-fetch(1)</a>, and how to merge two branches. So you can merge in changes from the @@ -718,7 +718,7 @@ repository that you pulled from.</p><p>(But note that no such commit will be cre updated to point to the latest commit from the upstream branch.)</p><p>The <code class="literal">git pull</code> command can also be given <code class="literal">.</code> as the "remote" repository, in which case it just merges in a branch from the current repository; so the commands</p><pre class="literallayout">$ git pull . branch -$ git merge branch</pre><p>are roughly equivalent.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="submitting-patches"></a>Submitting patches to a project</h3></div></div></div><p>If you just have a few changes, the simplest way to submit them may +$ git merge branch</pre><p>are roughly equivalent.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="submitting-patches"></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 class="ulink" href="git-format-patch.html" target="_top">git-format-patch(1)</a>; for example:</p><pre class="literallayout">$ git format-patch origin</pre><p>will produce a numbered series of files in the current directory, one for each patch in the current branch but not in <code class="literal">origin/HEAD</code>.</p><p><code class="literal">git format-patch</code> can include an initial "cover letter". You can insert commentary on individual patches after the three dash line which @@ -729,7 +729,7 @@ manner.</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 class="ulink" 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 -their requirements for submitting patches.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="importing-patches"></a>Importing patches to a project</h3></div></div></div><p>Git also provides a tool called <a class="ulink" href="git-am.html" target="_top">git-am(1)</a> (am stands for +their requirements for submitting patches.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="importing-patches"></a>Importing patches to a project</h2></div></div></div><p>Git also provides a tool called <a class="ulink" 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 <code class="literal">patches.mbox</code>, then run</p><pre class="literallayout">$ git am -3 patches.mbox</pre><p>Git will apply each patch in order; if any conflicts are found, it @@ -740,7 +740,7 @@ leave your tree and index untouched, you may omit that option.)</p><p>Once the i resolution, instead of creating a new commit, just run</p><pre class="literallayout">$ git am --continue</pre><p>and Git will create the commit for you and continue applying the remaining patches from the mailbox.</p><p>The final result will be a series of commits, one for each patch in the original mailbox, with authorship and commit log message each -taken from the message containing each patch.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="public-repositories"></a>Public Git repositories</h3></div></div></div><p>Another way to submit changes to a project is to tell the maintainer +taken from the message containing each patch.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="public-repositories"></a>Public Git repositories</h2></div></div></div><p>Another way to submit changes to a project is to tell the maintainer of that project to pull the changes from your repository using <a class="ulink" href="git-pull.html" target="_top">git-pull(1)</a>. In the section "<a class="link" href="#getting-updates-With-git-pull" title="Getting updates with git pull">Getting updates with <code class="literal">git pull</code></a>" we described this as a way to get updates from the "main" repository, but it works just as well in the @@ -765,14 +765,14 @@ your personal repo ------------------> your public repo | | | | | they push V -their public repo <------------------- their repo</pre><p>We explain how to do this in the following sections.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="setting-up-a-public-repository"></a>Setting up a public repository</h4></div></div></div><p>Assume your personal repository is in the directory <code class="literal">~/proj</code>. We +their public repo <------------------- their repo</pre><p>We explain how to do this in the following sections.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="setting-up-a-public-repository"></a>Setting up a public repository</h3></div></div></div><p>Assume your personal repository is in the directory <code class="literal">~/proj</code>. We first create a new clone of the repository and tell <code class="literal">git daemon</code> that it is meant to be public:</p><pre class="literallayout">$ git clone --bare ~/proj proj.git $ touch proj.git/git-daemon-export-ok</pre><p>The resulting directory proj.git contains a "bare" git repository—it is just the contents of the <code class="literal">.git</code> directory, without any files checked out around it.</p><p>Next, copy <code class="literal">proj.git</code> to the server where you plan to host the public repository. You can use scp, rsync, or whatever is most -convenient.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="exporting-via-git"></a>Exporting a Git repository via the Git protocol</h4></div></div></div><p>This is the preferred method.</p><p>If someone else administers the server, they should tell you what +convenient.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="exporting-via-git"></a>Exporting a Git repository via the Git protocol</h3></div></div></div><p>This is the preferred method.</p><p>If someone else administers the server, they should tell you what directory to put the repository in, and what <code class="literal">git://</code> URL it will appear at. You can then skip to the section "<a class="link" href="#pushing-changes-to-a-public-repository" title="Pushing changes to a public repository">Pushing changes to a public repository</a>", below.</p><p>Otherwise, all you need to do is start <a class="ulink" href="git-daemon.html" target="_top">git-daemon(1)</a>; it will @@ -781,7 +781,7 @@ that looks like a Git directory and contains the magic file git-daemon-export-ok. Passing some directory paths as <code class="literal">git daemon</code> arguments will further restrict the exports to those paths.</p><p>You can also run <code class="literal">git daemon</code> as an inetd service; see the <a class="ulink" href="git-daemon.html" target="_top">git-daemon(1)</a> man page for details. (See especially the -examples section.)</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="exporting-via-http"></a>Exporting a git repository via HTTP</h4></div></div></div><p>The Git protocol gives better performance and reliability, but on a +examples section.)</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="exporting-via-http"></a>Exporting a git repository via HTTP</h3></div></div></div><p>The Git protocol gives better performance and reliability, but on a host with a web server set up, HTTP exports may be simpler to set up.</p><p>All you need to do is place the newly created bare Git repository in a directory that is exported by the web server, and make some adjustments to give web clients some extra information they need:</p><pre class="literallayout">$ mv proj.git /home/you/public_html/proj.git @@ -792,7 +792,7 @@ $ mv hooks/post-update.sample hooks/post-update</pre><p>(For an explanation of t clone or pull from that URL, for example with a command line like:</p><pre class="literallayout">$ git clone http://yourserver.com/~you/proj.git</pre><p>(See also <a class="ulink" href="howto/setup-git-server-over-http.html" target="_top">setup-git-server-over-http</a> for a slightly more sophisticated setup using WebDAV which also -allows pushing over HTTP.)</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="pushing-changes-to-a-public-repository"></a>Pushing changes to a public repository</h4></div></div></div><p>Note that the two techniques outlined above (exporting via +allows pushing over HTTP.)</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="pushing-changes-to-a-public-repository"></a>Pushing changes to a public repository</h3></div></div></div><p>Note that the two techniques outlined above (exporting via <a class="link" href="#exporting-via-http" title="Exporting a git repository via HTTP">http</a> or <a class="link" href="#exporting-via-git" title="Exporting a Git repository via the Git protocol">git</a>) allow other maintainers to fetch your latest changes, but they do not allow write access, which you will need to update the public repository with the @@ -810,7 +810,7 @@ save typing; so, for example:</p><pre class="literallayout">$ git remote add pub url = yourserver.com:proj.git fetch = +refs/heads/*:refs/remotes/example/*</pre><p>which lets you do the same push with just</p><pre class="literallayout">$ git push public-repo master</pre><p>See the explanations of the <code class="literal">remote.<name>.url</code>, <code class="literal">branch.<name>.remote</code>, and <code class="literal">remote.<name>.push</code> options in -<a class="ulink" href="git-config.html" target="_top">git-config(1)</a> for details.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="forcing-push"></a>What to do when a push fails</h4></div></div></div><p>If a push would not result in a <a class="link" href="#fast-forwards" title="Fast-forward merges">fast-forward</a> of the +<a class="ulink" href="git-config.html" target="_top">git-config(1)</a> for details.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="forcing-push"></a>What to do when a push fails</h3></div></div></div><p>If a push would not result in a <a class="link" href="#fast-forwards" title="Fast-forward merges">fast-forward</a> of the remote branch, then it will fail with an error like:</p><pre class="literallayout">error: remote 'refs/heads/master' is not an ancestor of local 'refs/heads/master'. Maybe you are not up-to-date and need to pull first? @@ -835,7 +835,7 @@ the right to push to the same repository. In that case, the correct solution is to retry the push after first updating your work: either by a pull, or by a fetch followed by a rebase; see the <a class="link" href="#setting-up-a-shared-repository" title="Setting up a shared repository">next section</a> and -<a class="ulink" href="gitcvs-migration.html" target="_top">gitcvs-migration(7)</a> for more.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="setting-up-a-shared-repository"></a>Setting up a shared repository</h4></div></div></div><p>Another way to collaborate is by using a model similar to that +<a class="ulink" href="gitcvs-migration.html" target="_top">gitcvs-migration(7)</a> for more.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="setting-up-a-shared-repository"></a>Setting up a shared repository</h3></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 class="ulink" href="gitcvs-migration.html" target="_top">gitcvs-migration(7)</a> for instructions on how to @@ -860,14 +860,14 @@ Since every developer’s repository has the same complete copy The lack of a central group of "committers" means there is less need for formal decisions about who is "in" and who is "out". -</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="setting-up-gitweb"></a>Allowing web browsing of a repository</h4></div></div></div><p>The gitweb cgi script provides users an easy way to browse your +</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="setting-up-gitweb"></a>Allowing web browsing of a repository</h3></div></div></div><p>The gitweb cgi script provides users an easy way to browse your project’s revisions, file contents and logs without having to install Git. Features like RSS/Atom feeds and blame/annotation details may optionally be enabled.</p><p>The <a class="ulink" href="git-instaweb.html" target="_top">git-instaweb(1)</a> command provides a simple way to start browsing the repository using gitweb. The default server when using instaweb is lighttpd.</p><p>See the file gitweb/INSTALL in the Git source tree and <a class="ulink" href="gitweb.html" target="_top">gitweb(1)</a> for instructions on details setting up a permanent -installation with a CGI or Perl capable server.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="how-to-get-a-git-repository-with-minimal-history"></a>How to get a Git repository with minimal history</h3></div></div></div><p>A <a class="link" href="#def_shallow_clone">shallow clone</a>, with its truncated +installation with a CGI or Perl capable server.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="how-to-get-a-git-repository-with-minimal-history"></a>How to get a Git repository with minimal history</h2></div></div></div><p>A <a class="link" href="#def_shallow_clone">shallow clone</a>, with its truncated history, is useful when one is interested only in recent history of a project and getting full history from the upstream is expensive.</p><p>A <a class="link" href="#def_shallow_clone">shallow clone</a> is created by specifying @@ -877,7 +877,7 @@ history restored with <code class="literal">--unshallow</code>.</p><p>Merging in as a merge base is in the recent history. Otherwise, it will be like merging unrelated histories and may have to result in huge conflicts. This limitation may make such -a repository unsuitable to be used in merge based workflows.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="sharing-development-examples"></a>Examples</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="maintaining-topic-branches"></a>Maintaining topic branches for a Linux subsystem maintainer</h4></div></div></div><p>This describes how Tony Luck uses Git in his role as maintainer of the +a repository unsuitable to be used in merge based workflows.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sharing-development-examples"></a>Examples</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="maintaining-topic-branches"></a>Maintaining topic branches for a Linux subsystem maintainer</h3></div></div></div><p>This describes how Tony Luck uses Git in his role as maintainer of the IA64 architecture for the Linux kernel.</p><p>He uses two public branches:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> A "test" tree into which patches are initially placed so that they can get some exposure when integrated with other ongoing development. @@ -894,7 +894,7 @@ $ cd work</pre><p>Linus’s tree will be stored in the remote-tracking branch na and can be updated using <a class="ulink" href="git-fetch.html" target="_top">git-fetch(1)</a>; you can track other public trees using <a class="ulink" href="git-remote.html" target="_top">git-remote(1)</a> to set up a "remote" and <a class="ulink" href="git-fetch.html" target="_top">git-fetch(1)</a> to keep them up-to-date; see -<a class="xref" href="#repositories-and-branches" title="Repositories and Branches">the section called “Repositories and Branches”</a>.</p><p>Now create the branches in which you are going to work; these start out +<a class="xref" href="#repositories-and-branches" title="Chapter 1. Repositories and Branches">Chapter 1, <i>Repositories and Branches</i></a>.</p><p>Now create the branches in which you are going to work; these start out at the current tip of origin/master branch, and should be set up (using the <code class="literal">--track</code> option to <a class="ulink" href="git-branch.html" target="_top">git-branch(1)</a>) to merge changes in from Linus by default.</p><pre class="literallayout">$ git branch --track test origin/master @@ -1037,10 +1037,10 @@ do ;; esac git log origin/master..$branch | git shortlog -done</pre></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="cleaning-up-history"></a>Rewriting history and maintaining patch series</h2></div></div></div><p>Normally commits are only added to a project, never taken away or +done</pre></div></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="cleaning-up-history"></a>Chapter 5. Rewriting history and maintaining patch series</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#patch-series">Creating the perfect patch series</a></span></dt><dt><span class="section"><a href="#using-git-rebase">Keeping a patch series up to date using git rebase</a></span></dt><dt><span class="section"><a href="#rewriting-one-commit">Rewriting a single commit</a></span></dt><dt><span class="section"><a href="#reordering-patch-series">Reordering or selecting from a patch series</a></span></dt><dt><span class="section"><a href="#interactive-rebase">Using interactive rebases</a></span></dt><dt><span class="section"><a href="#patch-series-tools">Other tools</a></span></dt><dt><span class="section"><a href="#problems-With-rewriting-history">Problems with rewriting history</a></span></dt><dt><span class="section"><a href="#bisect-merges">Why bisecting merge commits can be harder than bisecting linear 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"><div class="titlepage"><div><div><h3 class="title"><a name="patch-series"></a>Creating the perfect patch series</h3></div></div></div><p>Suppose you are a contributor to a large project, and you want to add a +assumption.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="patch-series"></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 @@ -1059,7 +1059,7 @@ The complete series produces the same end result as your own (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"><div class="titlepage"><div><div><h3 class="title"><a name="using-git-rebase"></a>Keeping a patch series up to date using git rebase</h3></div></div></div><p>Suppose that you create a branch <code class="literal">mywork</code> on a remote-tracking branch +you are rewriting history.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="using-git-rebase"></a>Keeping a patch series up to date using git rebase</h2></div></div></div><p>Suppose that you create a branch <code class="literal">mywork</code> on a remote-tracking branch <code class="literal">origin</code>, and create some commits on top of it:</p><pre class="literallayout">$ git checkout -b mywork origin $ vi file.txt $ git commit @@ -1090,16 +1090,16 @@ return mywork to the state it had before you started the rebase:</p><pre class=" be easier to use <code class="literal">git rebase -i</code>, which allows you to reorder and squash commits, as well as marking them for individual editing during the rebase. See <a class="xref" href="#interactive-rebase" title="Using interactive rebases">the section called “Using interactive rebases”</a> for details, and -<a class="xref" href="#reordering-patch-series" title="Reordering or selecting from a patch series">the section called “Reordering or selecting from a patch series”</a> for alternatives.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="rewriting-one-commit"></a>Rewriting a single commit</h3></div></div></div><p>We saw in <a class="xref" href="#fixing-a-mistake-by-rewriting-history" title="Fixing a mistake by rewriting history">the section called “Fixing a mistake by rewriting history”</a> that you can replace the +<a class="xref" href="#reordering-patch-series" title="Reordering or selecting from a patch series">the section called “Reordering or selecting from a patch series”</a> for alternatives.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="rewriting-one-commit"></a>Rewriting a single commit</h2></div></div></div><p>We saw in <a class="xref" href="#fixing-a-mistake-by-rewriting-history" title="Fixing a mistake by rewriting history">the section called “Fixing a mistake by rewriting history”</a> that you can replace the most recent commit using</p><pre class="literallayout">$ git commit --amend</pre><p>which will replace the old commit by a new commit incorporating your changes, giving you a chance to edit the old commit message first. This is useful for fixing typos in your last commit, or for adjusting the patch contents of a poorly staged commit.</p><p>If you need to amend commits from deeper in your history, you can -use <a class="link" href="#interactive-rebase" title="Using interactive rebases">interactive rebase’s <code class="literal">edit</code> instruction</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="reordering-patch-series"></a>Reordering or selecting from a patch series</h3></div></div></div><p>Sometimes you want to edit a commit deeper in your history. One +use <a class="link" href="#interactive-rebase" title="Using interactive rebases">interactive rebase’s <code class="literal">edit</code> instruction</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="reordering-patch-series"></a>Reordering or selecting from a patch series</h2></div></div></div><p>Sometimes you want to edit a commit deeper in your history. One approach is to use <code class="literal">git format-patch</code> to create a series of patches and then reset the state to before the patches:</p><pre class="literallayout">$ git format-patch origin $ git reset --hard origin</pre><p>Then modify, reorder, or eliminate patches as needed before applying -them again with <a class="ulink" href="git-am.html" target="_top">git-am(1)</a>:</p><pre class="literallayout">$ git am *.patch</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="interactive-rebase"></a>Using interactive rebases</h3></div></div></div><p>You can also edit a patch series with an interactive rebase. This is +them again with <a class="ulink" href="git-am.html" target="_top">git-am(1)</a>:</p><pre class="literallayout">$ git am *.patch</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="interactive-rebase"></a>Using interactive rebases</h2></div></div></div><p>You can also edit a patch series with an interactive rebase. This is the same as <a class="link" href="#reordering-patch-series" title="Reordering or selecting from a patch series">reordering a patch series using <code class="literal">format-patch</code></a>, so use whichever interface you like best.</p><p>Rebase your current HEAD on the last commit you want to retain as-is. For example, if you want to reorder the last 5 commits, use:</p><pre class="literallayout">$ git rebase -i HEAD~5</pre><p>This will open your editor with a list of steps to be taken to perform your rebase.</p><pre class="literallayout">pick deadbee The oneline of this commit @@ -1132,9 +1132,9 @@ you can continue with <code class="literal">git rebase --continue</code>. If yo things are getting too hairy, you can always bail out with <code class="literal">git rebase --abort</code>. Even after the rebase is complete, you can still recover the original branch by using the <a class="link" href="#reflogs" title="Reflogs">reflog</a>.</p><p>For a more detailed discussion of the procedure and additional tips, -see the "INTERACTIVE MODE" section of <a class="ulink" href="git-rebase.html" target="_top">git-rebase(1)</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="patch-series-tools"></a>Other tools</h3></div></div></div><p>There are numerous other tools, such as StGit, which exist for the +see the "INTERACTIVE MODE" section of <a class="ulink" href="git-rebase.html" target="_top">git-rebase(1)</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="patch-series-tools"></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"><div class="titlepage"><div><div><h3 class="title"><a name="problems-With-rewriting-history"></a>Problems with rewriting history</h3></div></div></div><p>The primary problem with rewriting the history of a branch has to do +this manual.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="problems-With-rewriting-history"></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 \ \ @@ -1155,7 +1155,7 @@ new. The results are likely to be unexpected.</p><p>You may still choose to pub 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 class="section"><div class="titlepage"><div><div><h3 class="title"><a name="bisect-merges"></a>Why bisecting merge commits can be harder than bisecting linear history</h3></div></div></div><p>The <a class="ulink" href="git-bisect.html" target="_top">git-bisect(1)</a> command correctly handles history that +published branches should never be rewritten.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="bisect-merges"></a>Why bisecting merge commits can be harder than bisecting linear history</h2></div></div></div><p>The <a class="ulink" href="git-bisect.html" target="_top">git-bisect(1)</a> command correctly handles history that includes merge commits. However, when the commit that it finds is a merge commit, the user may need to work harder than usual to figure out why that commit introduced a problem.</p><p>Imagine this history:</p><pre class="literallayout"> ---Z---o---X---...---o---A---C---D @@ -1189,7 +1189,7 @@ linear history:</p><pre class="literallayout"> ---Z---o---X--...---o---A---o- and understanding why Y* was broken would probably be easier.</p><p>Partly for this reason, many experienced Git users, even when working on an otherwise merge-heavy project, keep the history linear by rebasing against the latest upstream version before -publishing.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="advanced-branch-management"></a>Advanced branch management</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="fetching-individual-branches"></a>Fetching individual branches</h3></div></div></div><p>Instead of using <a class="ulink" href="git-remote.html" target="_top">git-remote(1)</a>, you can also choose just +publishing.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="advanced-branch-management"></a>Chapter 6. Advanced branch management</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#fetching-individual-branches">Fetching individual branches</a></span></dt><dt><span class="section"><a href="#fetch-fast-forwards">git fetch and fast-forwards</a></span></dt><dt><span class="section"><a href="#forcing-fetch">Forcing git fetch to do non-fast-forward updates</a></span></dt><dt><span class="section"><a href="#remote-branch-configuration">Configuring remote-tracking branches</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="fetching-individual-branches"></a>Fetching individual branches</h2></div></div></div><p>Instead of using <a class="ulink" 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><pre class="literallayout">$ git fetch origin todo:my-todo-work</pre><p>The first argument, <code class="literal">origin</code>, just tells Git to fetch from the repository you originally cloned from. The second argument tells Git @@ -1198,7 +1198,7 @@ store it locally under the name <code class="literal">refs/heads/my-todo-work</c branch named <code class="literal">master</code> from the repository at the given URL. If you already have a branch named example-master, it will attempt to <a class="link" href="#fast-forwards" title="Fast-forward merges">fast-forward</a> to the commit given by example.com’s -master branch. In more detail:</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="fetch-fast-forwards"></a>git fetch and fast-forwards</h3></div></div></div><p>In the previous example, when updating an existing branch, <code class="literal">git fetch</code> +master branch. In more detail:</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="fetch-fast-forwards"></a>git fetch and fast-forwards</h2></div></div></div><p>In the previous example, when updating an existing branch, <code class="literal">git fetch</code> checks to make sure that the most recent commit on the remote branch is a descendant of the most recent commit on your copy of the branch before updating your copy of the branch to point at the new @@ -1213,10 +1213,10 @@ resulting in a situation like:</p><pre class="literallayout"> o--o--o--o--a--b & described in the following section. However, note that in the situation above this may mean losing the commits labeled <code class="literal">a</code> and <code class="literal">b</code>, unless you’ve already created a reference of your own pointing to -them.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="forcing-fetch"></a>Forcing git fetch to do non-fast-forward updates</h3></div></div></div><p>If git fetch fails because the new head of a branch is not a +them.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="forcing-fetch"></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><pre class="literallayout">$ git fetch git://example.com/proj.git +master:refs/remotes/example/master</pre><p>Note the addition of the <code class="literal">+</code> sign. Alternatively, you can use the <code class="literal">-f</code> flag to force updates of all the fetched branches, as in:</p><pre class="literallayout">$ git fetch -f origin</pre><p>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"><div class="titlepage"><div><div><h3 class="title"><a name="remote-branch-configuration"></a>Configuring remote-tracking branches</h3></div></div></div><p>We saw above that <code class="literal">origin</code> is just a shortcut to refer to the +may be lost, as we saw in the previous section.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="remote-branch-configuration"></a>Configuring remote-tracking branches</h2></div></div></div><p>We saw above that <code class="literal">origin</code> 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 class="ulink" href="git-config.html" target="_top">git-config(1)</a>:</p><pre class="literallayout">$ git config -l @@ -1235,9 +1235,9 @@ same thing:</p><pre class="literallayout">$ git fetch git://example.com/proj.git $ git fetch example +refs/heads/*:refs/remotes/example/* $ git fetch example</pre><p>See <a class="ulink" href="git-config.html" target="_top">git-config(1)</a> for more details on the configuration options mentioned above and <a class="ulink" href="git-fetch.html" target="_top">git-fetch(1)</a> for more details on -the refspec syntax.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="git-concepts"></a>Git concepts</h2></div></div></div><p>Git is built on a small number of simple but powerful ideas. While it +the refspec syntax.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="git-concepts"></a>Chapter 7. Git concepts</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#the-object-database">The Object Database</a></span></dt><dd><dl><dt><span class="section"><a href="#commit-object">Commit Object</a></span></dt><dt><span class="section"><a href="#tree-object">Tree Object</a></span></dt><dt><span class="section"><a href="#blob-object">Blob Object</a></span></dt><dt><span class="section"><a href="#trust">Trust</a></span></dt><dt><span class="section"><a href="#tag-object">Tag Object</a></span></dt><dt><span class="section"><a href="#pack-files">How Git stores objects efficiently: pack files</a></span></dt><dt><span class="section"><a href="#dangling-objects">Dangling objects</a></span></dt><dt><span class="section"><a href="#recovering-from-repository-corruption">Recovering from repository corruption</a></span></dt></dl></dd><dt><span class="section"><a href="#the-index">The index</a></span></dt></dl></div><p>Git is built on a small number of simple but powerful ideas. While it is possible to get things done without understanding them, you will find -Git much more intuitive if you do.</p><p>We start with the most important, the <a class="link" href="#def_object_database">object database</a> and the <a class="link" href="#def_index">index</a>.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="the-object-database"></a>The Object Database</h3></div></div></div><p>We already saw in <a class="xref" href="#understanding-commits" title="Understanding History: Commits">the section called “Understanding History: Commits”</a> that all commits are stored +Git much more intuitive if you do.</p><p>We start with the most important, the <a class="link" href="#def_object_database">object database</a> and the <a class="link" href="#def_index">index</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="the-object-database"></a>The Object Database</h2></div></div></div><p>We already saw in <a class="xref" href="#understanding-commits" title="Understanding History: Commits">the section called “Understanding History: Commits”</a> that all commits are stored under a 40-digit "object name". In fact, all the information needed to represent the history of a project is stored in objects with such names. In each case the name is calculated by taking the SHA-1 hash of the @@ -1274,7 +1274,7 @@ A <a class="link" href="#def_tag_object">"tag" object</a> symbolically identifie used to sign other objects. It contains the object name and type of another object, a symbolic name (of course!) and, optionally, a signature. -</li></ul></div><p>The object types in some more detail:</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="commit-object"></a>Commit Object</h4></div></div></div><p>The "commit" object links a physical state of a tree with a description +</li></ul></div><p>The object types in some more detail:</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="commit-object"></a>Commit Object</h3></div></div></div><p>The "commit" object links a physical state of a tree with a description of how we got there and why. Use the <code class="literal">--pretty=raw</code> option to <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> or <a class="ulink" href="git-log.html" target="_top">git-log(1)</a> to examine your favorite commit:</p><pre class="literallayout">$ git show -s --pretty=raw 2be7fcb476 @@ -1315,7 +1315,7 @@ explicitly, though it can identify cases where the existence of the same file data at changing paths suggests a rename. (See, for example, the <code class="literal">-M</code> option to <a class="ulink" href="git-diff.html" target="_top">git-diff(1)</a>).</p><p>A commit is usually created by <a class="ulink" href="git-commit.html" target="_top">git-commit(1)</a>, which creates a commit whose parent is normally the current HEAD, and whose tree is -taken from the content currently stored in the index.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="tree-object"></a>Tree Object</h4></div></div></div><p>The ever-versatile <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> command can also be used to +taken from the content currently stored in the index.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="tree-object"></a>Tree Object</h3></div></div></div><p>The ever-versatile <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> command can also be used to examine tree objects, but <a class="ulink" href="git-ls-tree.html" target="_top">git-ls-tree(1)</a> will give you more details:</p><pre class="literallayout">$ git ls-tree fb3a8bdd0ce 100644 blob 63c918c667fa005ff12ad89437f2fdc80926e21c .gitignore @@ -1336,8 +1336,8 @@ contents (including, recursively, the contents of all subdirectories) are identical. This allows Git to quickly determine the differences between two related tree objects, since it can ignore any entries with identical object names.</p><p>(Note: in the presence of submodules, trees may also have commits as -entries. See <a class="xref" href="#submodules" title="Submodules">the section called “Submodules”</a> for documentation.)</p><p>Note that the files all have mode 644 or 755: Git actually only pays -attention to the executable bit.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="blob-object"></a>Blob Object</h4></div></div></div><p>You can use <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> to examine the contents of a blob; take, +entries. See <a class="xref" href="#submodules" title="Chapter 8. Submodules">Chapter 8, <i>Submodules</i></a> for documentation.)</p><p>Note that the files all have mode 644 or 755: Git actually only pays +attention to the executable bit.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="blob-object"></a>Blob Object</h3></div></div></div><p>You can use <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> to examine the contents of a blob; take, for example, the blob in the entry for <code class="literal">COPYING</code> from the tree above:</p><pre class="literallayout">$ git show 6ff87c4664 Note that the only valid version of the GPL as far as this project @@ -1351,7 +1351,7 @@ is totally independent of its location in the directory tree, and renaming a file does not change the object that file is associated with.</p><p>Note that any tree or blob object can be examined using <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> with the <revision>:<path> syntax. This can sometimes be useful for browsing the contents of a tree that is not -currently checked out.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="trust"></a>Trust</h4></div></div></div><p>If you receive the SHA-1 name of a blob from one source, and its contents +currently checked out.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="trust"></a>Trust</h3></div></div></div><p>If you receive the SHA-1 name of a blob from one source, and its contents from another (possibly untrusted) source, you can still trust that those contents are correct as long as the SHA-1 name agrees. This is because the SHA-1 is designed so that it is infeasible to find different contents @@ -1367,7 +1367,7 @@ that you trust that commit, and the immutability of the history of 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 (SHA-1 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"><div class="titlepage"><div><div><h4 class="title"><a name="tag-object"></a>Tag Object</h4></div></div></div><p>A tag object contains an object, object type, tag name, the name of the +like GPG/PGP.</p><p>To assist in this, Git also provides the tag object…</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="tag-object"></a>Tag Object</h3></div></div></div><p>A tag object contains an object, object type, tag name, the name of the person ("tagger") who created the tag, and a message, which may contain a signature, as can be seen using <a class="ulink" href="git-cat-file.html" target="_top">git-cat-file(1)</a>:</p><pre class="literallayout">$ git cat-file tag v1.5.0 object 437b1b20df4b356c9342dac8d38849f24ef44f27 @@ -1385,7 +1385,7 @@ nLE/L9aUXdWeTFPron96DLA= -----END PGP SIGNATURE-----</pre><p>See the <a class="ulink" href="git-tag.html" target="_top">git-tag(1)</a> command to learn how to create and verify tag objects. (Note that <a class="ulink" href="git-tag.html" target="_top">git-tag(1)</a> can also be used to create "lightweight tags", which are not tag objects at all, but just simple -references whose names begin with <code class="literal">refs/tags/</code>).</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="pack-files"></a>How Git stores objects efficiently: pack files</h4></div></div></div><p>Newly created objects are initially created in a file named after the +references whose names begin with <code class="literal">refs/tags/</code>).</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="pack-files"></a>How Git stores objects efficiently: pack files</h3></div></div></div><p>Newly created objects are initially created in a file named after the object’s SHA-1 hash (stored in <code class="literal">.git/objects</code>).</p><p>Unfortunately this system becomes inefficient once a project has a lot of objects. Try this on an old project:</p><pre class="literallayout">$ git count-objects 6930 objects, 47620 kilobytes</pre><p>The first number is the number of objects which are kept in @@ -1406,10 +1406,10 @@ You can verify that the loose objects are gone by looking at the <code class="literal">.git/objects</code> directory or by running</p><pre class="literallayout">$ git count-objects 0 objects, 0 kilobytes</pre><p>Although the object files are gone, any commands that refer to those objects will work exactly as they did before.</p><p>The <a class="ulink" href="git-gc.html" target="_top">git-gc(1)</a> command performs packing, pruning, and more for -you, so is normally the only high-level command you need.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="dangling-objects"></a>Dangling objects</h4></div></div></div><p>The <a class="ulink" href="git-fsck.html" target="_top">git-fsck(1)</a> command will sometimes complain about dangling +you, so is normally the only high-level command you need.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="dangling-objects"></a>Dangling objects</h3></div></div></div><p>The <a class="ulink" href="git-fsck.html" target="_top">git-fsck(1)</a> command will sometimes complain about dangling objects. They are not a problem.</p><p>The most common cause of dangling objects is that you’ve rebased a branch, or you have pulled from somebody else who rebased a branch—see -<a class="xref" href="#cleaning-up-history" title="Rewriting history and maintaining patch series">the section called “Rewriting history and maintaining patch series”</a>. In that case, the old head of the original +<a class="xref" href="#cleaning-up-history" title="Chapter 5. Rewriting history and maintaining patch series">Chapter 5, <i>Rewriting history and maintaining patch series</i></a>. In that case, the old head of the original branch still exists, as does everything it pointed to. The branch pointer itself just doesn’t, since you replaced it with another one.</p><p>There are also other situations that cause dangling objects. For example, a "dangling blob" may arise because you did a <code class="literal">git add</code> of a @@ -1443,7 +1443,7 @@ state, you can just prune all unreachable objects:</p><pre class="literallayout" repository—it’s kind of like doing a filesystem fsck recovery: you don’t want to do that while the filesystem is mounted. <code class="literal">git prune</code> is designed not to cause any harm in such cases of concurrent -accesses to a repository but you might receive confusing or scary messages.)</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="recovering-from-repository-corruption"></a>Recovering from repository corruption</h4></div></div></div><p>By design, Git treats data trusted to it with caution. However, even in +accesses to a repository but you might receive confusing or scary messages.)</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="recovering-from-repository-corruption"></a>Recovering from repository corruption</h3></div></div></div><p>By design, Git treats data trusted to it with caution. However, even in the absence of bugs in Git itself, it is still possible that hardware or operating system errors could corrupt data.</p><p>The first defense against such problems is backups. You can back up a Git directory using clone, or just using cp, tar, or any other backup @@ -1493,7 +1493,7 @@ You also know the commit messages that went with the change from oldsha to 4b9458b and with the change from 4b9458b to newsha.</p><p>If you’ve been committing small enough changes, you may now have a good shot at reconstructing the contents of the in-between state 4b9458b.</p><p>If you can do that, you can now recreate the missing object with</p><pre class="literallayout">$ git hash-object -w <recreated-file></pre><p>and your repository is good again!</p><p>(Btw, you could have ignored the <code class="literal">fsck</code>, and started with doing a</p><pre class="literallayout">$ git log --raw --all</pre><p>and just looked for the sha of the missing object (4b9458b..) in that whole thing. It’s up to you—Git does <span class="strong"><strong>have</strong></span> a lot of information, it is -just missing one particular blob version.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="the-index"></a>The index</h3></div></div></div><p>The index is a binary file (generally kept in <code class="literal">.git/index</code>) containing a +just missing one particular blob version.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="the-index"></a>The index</h2></div></div></div><p>The index is a binary file (generally kept in <code class="literal">.git/index</code>) containing a sorted list of path names, each with permissions and the SHA-1 of a blob object; <a class="ulink" href="git-ls-files.html" target="_top">git-ls-files(1)</a> can show you the contents of the index:</p><pre class="literallayout">$ git ls-files --stage 100644 63c918c667fa005ff12ad89437f2fdc80926e21c 0 .gitignore @@ -1530,7 +1530,7 @@ column in the <a class="ulink" href="git-ls-files.html" target="_top">git-ls-fil number, and will take on values other than 0 for files with merge conflicts.</p></li></ol></div><p>The index is thus a sort of temporary staging area, which is filled with a tree which you are in the process of working on.</p><p>If you blow the index away entirely, you generally haven’t lost any -information as long as you have the name of the tree that it described.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="submodules"></a>Submodules</h2></div></div></div><p>Large projects are often composed of smaller, self-contained modules. For +information as long as you have the name of the tree that it described.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="submodules"></a>Chapter 8. Submodules</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#_pitfalls_with_submodules">Pitfalls with submodules</a></span></dt></dl></div><p>Large projects are often composed of smaller, self-contained modules. For example, an embedded Linux distribution’s source tree would include every piece of software in the distribution with some local modifications; a movie player might need to build against a specific, known-working version of a @@ -1624,7 +1624,7 @@ index d266b98..261dfac 160000 $ git add a $ git commit -m "Updated submodule a." $ git push</pre><p>You have to run <code class="literal">git submodule update</code> after <code class="literal">git pull</code> if you want to update -submodules, too.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_pitfalls_with_submodules"></a>Pitfalls with submodules</h3></div></div></div><p>Always publish the submodule change before publishing the change to the +submodules, too.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_pitfalls_with_submodules"></a>Pitfalls with submodules</h2></div></div></div><p>Always publish the submodule change before publishing the change to the superproject that references it. If you forget to publish the submodule change, others won’t be able to clone the repository:</p><pre class="literallayout">$ cd ~/git/super/a $ echo i added another line to this file >> a.txt @@ -1666,16 +1666,16 @@ $ cd a $ cat a.txt module a</pre><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The changes are still visible in the submodule’s reflog.</p></div><p>If you have uncommitted changes in your submodule working tree, <code class="literal">git submodule update</code> will not overwrite them. Instead, you get the usual -warning about not being able switch from a dirty branch.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="low-level-operations"></a>Low-level Git operations</h2></div></div></div><p>Many of the higher-level commands were originally implemented as shell +warning about not being able switch from a dirty branch.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="low-level-operations"></a>Chapter 9. Low-level Git operations</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#object-manipulation">Object access and manipulation</a></span></dt><dt><span class="section"><a href="#the-workflow">The Workflow</a></span></dt><dd><dl><dt><span class="section"><a href="#working-directory-to-index">working directory → index</a></span></dt><dt><span class="section"><a href="#index-to-object-database">index → object database</a></span></dt><dt><span class="section"><a href="#object-database-to-index">object database → index</a></span></dt><dt><span class="section"><a href="#index-to-working-directory">index → working directory</a></span></dt><dt><span class="section"><a href="#tying-it-all-together">Tying it all together</a></span></dt></dl></dd><dt><span class="section"><a href="#examining-the-data">Examining the data</a></span></dt><dt><span class="section"><a href="#merging-multiple-trees">Merging multiple trees</a></span></dt><dt><span class="section"><a href="#merging-multiple-trees-2">Merging multiple trees, continued</a></span></dt></dl></div><p>Many of the higher-level commands were originally implemented as shell scripts using a smaller core of low-level Git commands. These can still be useful when doing unusual things with Git, or just as a way to -understand its inner workings.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="object-manipulation"></a>Object access and manipulation</h3></div></div></div><p>The <a class="ulink" href="git-cat-file.html" target="_top">git-cat-file(1)</a> command can show the contents of any object, +understand its inner workings.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="object-manipulation"></a>Object access and manipulation</h2></div></div></div><p>The <a class="ulink" href="git-cat-file.html" target="_top">git-cat-file(1)</a> command can show the contents of any object, though the higher-level <a class="ulink" href="git-show.html" target="_top">git-show(1)</a> is usually more useful.</p><p>The <a class="ulink" href="git-commit-tree.html" target="_top">git-commit-tree(1)</a> command allows constructing commits with arbitrary parents and trees.</p><p>A tree can be created with <a class="ulink" href="git-write-tree.html" target="_top">git-write-tree(1)</a> and its data can be accessed by <a class="ulink" href="git-ls-tree.html" target="_top">git-ls-tree(1)</a>. Two trees can be compared with <a class="ulink" href="git-diff-tree.html" target="_top">git-diff-tree(1)</a>.</p><p>A tag is created with <a class="ulink" href="git-mktag.html" target="_top">git-mktag(1)</a>, and the signature can be verified by <a class="ulink" href="git-verify-tag.html" target="_top">git-verify-tag(1)</a>, though it is normally simpler to -use <a class="ulink" href="git-tag.html" target="_top">git-tag(1)</a> for both.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="the-workflow"></a>The Workflow</h3></div></div></div><p>High-level operations such as <a class="ulink" href="git-commit.html" target="_top">git-commit(1)</a>, +use <a class="ulink" href="git-tag.html" target="_top">git-tag(1)</a> for both.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="the-workflow"></a>The Workflow</h2></div></div></div><p>High-level operations such as <a class="ulink" href="git-commit.html" target="_top">git-commit(1)</a>, <a class="ulink" href="git-checkout.html" target="_top">git-checkout(1)</a> and <a class="ulink" href="git-reset.html" target="_top">git-reset(1)</a> work by moving data between the working tree, the index, and the object database. Git provides low-level operations which perform each of these steps @@ -1683,7 +1683,7 @@ individually.</p><p>Generally, all Git operations work on the index file. Some o work <span class="strong"><strong>purely</strong></span> on the index file (showing the current state of the index), but most operations move data between the index file and either the database or the working directory. Thus there are four main -combinations:</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="working-directory-to-index"></a>working directory → index</h4></div></div></div><p>The <a class="ulink" href="git-update-index.html" target="_top">git-update-index(1)</a> command updates the index with +combinations:</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="working-directory-to-index"></a>working directory → index</h3></div></div></div><p>The <a class="ulink" href="git-update-index.html" target="_top">git-update-index(1)</a> command updates the index with information from the working directory. You generally update the index information by just specifying the filename you want to update, like so:</p><pre class="literallayout">$ git update-index filename</pre><p>but to avoid common mistakes with filename globbing etc., the command @@ -1700,16 +1700,16 @@ 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><p>The previously introduced <a class="ulink" href="git-add.html" target="_top">git-add(1)</a> is just a wrapper for -<a class="ulink" href="git-update-index.html" target="_top">git-update-index(1)</a>.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="index-to-object-database"></a>index → object database</h4></div></div></div><p>You write your current index file to a "tree" object with the program</p><pre class="literallayout">$ git write-tree</pre><p>that doesn’t come with any options—it will just write out the +<a class="ulink" href="git-update-index.html" target="_top">git-update-index(1)</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="index-to-object-database"></a>index → object database</h3></div></div></div><p>You write your current index file to a "tree" object with the program</p><pre class="literallayout">$ git write-tree</pre><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"><div class="titlepage"><div><div><h4 class="title"><a name="object-database-to-index"></a>object database → index</h4></div></div></div><p>You read a "tree" file from the object database, and use that to +other direction:</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="object-database-to-index"></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><pre class="literallayout">$ git read-tree <SHA-1 of tree></pre><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"><div class="titlepage"><div><div><h4 class="title"><a name="index-to-working-directory"></a>index → working directory</h4></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"><div class="titlepage"><div><div><h3 class="title"><a name="index-to-working-directory"></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 @@ -1720,7 +1720,7 @@ with</p><pre class="literallayout">$ git checkout-index filename</pre><p>or, if if you have an old version of the tree already checked out, you will need to use the <code class="literal">-f</code> flag (<span class="emphasis"><em>before</em></span> the <code class="literal">-a</code> 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"><div class="titlepage"><div><div><h4 class="title"><a name="tying-it-all-together"></a>Tying it all together</h4></div></div></div><p>To commit a tree you have instantiated with <code class="literal">git write-tree</code>, you’d +from one representation to the other:</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="tying-it-all-together"></a>Tying it all together</h3></div></div></div><p>To commit a tree you have instantiated with <code class="literal">git write-tree</code>, 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 @@ -1766,7 +1766,7 @@ what the last committed state was.</p><p>Here is a picture that illustrates how +-----------+ | Working | | Directory | - +-----------+</pre></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="examining-the-data"></a>Examining the data</h3></div></div></div><p>You can examine the data represented in the object database and the + +-----------+</pre></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="examining-the-data"></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 class="ulink" href="git-cat-file.html" target="_top">git-cat-file(1)</a> to examine details about the object:</p><pre class="literallayout">$ git cat-file -t <objectname></pre><p>shows the type of the object, and once you have the type (which is @@ -1776,7 +1776,7 @@ there is a special helper for showing that content, called 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><pre class="literallayout">$ git cat-file commit HEAD</pre><p>to see what the top commit was.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="merging-multiple-trees"></a>Merging multiple trees</h3></div></div></div><p>Git can help you perform a three-way merge, which can in turn be +you can do</p><pre class="literallayout">$ git cat-file commit HEAD</pre><p>to see what the top commit was.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="merging-multiple-trees"></a>Merging multiple trees</h2></div></div></div><p>Git can help you perform a three-way merge, which can in turn be used for a many-way merge by repeating the merge procedure several times. The usual situation is that you only do one three-way merge (reconciling two lines of history) and commit the result, but if @@ -1794,7 +1794,7 @@ make sure that you’ve committed those—in fact you would normally 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><pre class="literallayout">$ git read-tree -m -u <origtree> <yourtree> <targettree></pre><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"><div class="titlepage"><div><div><h3 class="title"><a name="merging-multiple-trees-2"></a>Merging multiple trees, continued</h3></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"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="merging-multiple-trees-2"></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 @@ -1829,8 +1829,8 @@ that path tells Git to mark the path resolved.</p><p>The above is the descriptio to help you understand what conceptually happens under the hood. In practice, nobody, not even Git itself, runs <code class="literal">git cat-file</code> three times for this. There is a <code class="literal">git merge-index</code> program that extracts the -stages to temporary files and calls a "merge" script on it:</p><pre class="literallayout">$ git merge-index git-merge-one-file hello.c</pre><p>and that is what higher level <code class="literal">git merge -s resolve</code> is implemented with.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="hacking-git"></a>Hacking Git</h2></div></div></div><p>This chapter covers internal details of the Git implementation which -probably only Git developers need to understand.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="object-details"></a>Object storage format</h3></div></div></div><p>All objects have a statically determined "type" which identifies the +stages to temporary files and calls a "merge" script on it:</p><pre class="literallayout">$ git merge-index git-merge-one-file hello.c</pre><p>and that is what higher level <code class="literal">git merge -s resolve</code> is implemented with.</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="hacking-git"></a>Chapter 10. Hacking Git</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#object-details">Object storage format</a></span></dt><dt><span class="section"><a href="#birdview-on-the-source-code">A birds-eye view of Git’s source code</a></span></dt></dl></div><p>This chapter covers internal details of the Git implementation which +probably only Git developers need to understand.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="object-details"></a>Object storage format</h2></div></div></div><p>All objects have a statically determined "type" which identifies the format of the object (i.e. how it is used, and how it can refer to other objects). There are currently four different object types: "blob", "tree", "commit", and "tag".</p><p>Regardless of object type, all objects share the following @@ -1849,7 +1849,7 @@ forms a sequence of 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></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="birdview-on-the-source-code"></a>A birds-eye view of Git’s source code</h3></div></div></div><p>It is not always easy for new developers to find their way through Git’s +to just verifying their superficial consistency through the hash).</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="birdview-on-the-source-code"></a>A birds-eye view of Git’s source code</h2></div></div></div><p>It is not always easy for new developers to find their way through Git’s source code. This section gives you a little guidance to show where to start.</p><p>A good place to start is with the contents of the initial commit, with:</p><pre class="literallayout">$ git checkout e83c5163</pre><p>The initial revision lays the foundation for almost everything Git has today, but is small enough to read in one sitting.</p><p>Note that terminology has changed since that revision. For example, the @@ -1947,7 +1947,7 @@ does not illustrate the point!):</p><pre class="literallayout">$ git log --no-me and see that it is in commit 18449ab0… Now just copy this object name, and paste it into the command line</p><pre class="literallayout">$ git show 18449ab0</pre><p>Voila.</p><p>Another example: Find out what to do in order to make some script a builtin:</p><pre class="literallayout">$ git log --no-merges --diff-filter=A builtin/*.c</pre><p>You see, Git is actually the best tool to find out about the source of Git -itself!</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="glossary"></a>Git Glossary</h2></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term"> +itself!</p></div></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="glossary"></a>Chapter 11. Git Glossary</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#git-explained">Git explained</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="git-explained"></a>Git explained</h2></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term"> <a name="def_alternate_object_database"></a>alternate object database </span></dt><dd> Via the alternates mechanism, a <a class="link" href="#def_repository">repository</a> @@ -2634,14 +2634,14 @@ The most notable example is <code class="literal">HEAD</code>.</p></dd><dt><span The tree of actual checked out files. The working tree normally contains the contents of the <a class="link" href="#def_HEAD">HEAD</a> commit’s tree, plus any local changes that you have made but not yet committed. -</dd></dl></div></div><div class="appendix"><h2 class="title" style="clear: both"><a name="git-quick-start"></a>A. Git Quick Reference</h2><p>This is a quick summary of the major commands; the previous chapters -explain how these work in more detail.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="quick-creating-a-new-repository"></a>Creating a new repository</h3></div></div></div><p>From a tarball:</p><pre class="literallayout">$ tar xzf project.tar.gz +</dd></dl></div></div></div><div class="appendix"><div class="titlepage"><div><div><h1 class="title"><a name="git-quick-start"></a>Appendix A. Git Quick Reference</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#quick-creating-a-new-repository">Creating a new repository</a></span></dt><dt><span class="section"><a href="#managing-branches">Managing branches</a></span></dt><dt><span class="section"><a href="#exploring-history">Exploring history</a></span></dt><dt><span class="section"><a href="#making-changes">Making changes</a></span></dt><dt><span class="section"><a href="#merging">Merging</a></span></dt><dt><span class="section"><a href="#sharing-your-changes">Sharing your changes</a></span></dt><dt><span class="section"><a href="#repository-maintenance">Repository maintenance</a></span></dt></dl></div><p>This is a quick summary of the major commands; the previous chapters +explain how these work in more detail.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="quick-creating-a-new-repository"></a>Creating a new repository</h2></div></div></div><p>From a tarball:</p><pre class="literallayout">$ tar xzf project.tar.gz $ cd project $ git init Initialized empty Git repository in .git/ $ git add . $ git commit</pre><p>From a remote repository:</p><pre class="literallayout">$ git clone git://example.com/pub/project.git -$ cd project</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="managing-branches"></a>Managing branches</h3></div></div></div><pre class="literallayout">$ git branch # list all local branches in this repo +$ cd project</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="managing-branches"></a>Managing branches</h2></div></div></div><pre class="literallayout">$ git branch # list all local branches in this repo $ git checkout test # switch working directory to branch "test" $ git branch new # create branch "new" starting at current HEAD $ git branch -d new # delete branch "new"</pre><p>Instead of basing a new branch on current HEAD (the default), use:</p><pre class="literallayout">$ git branch new test # branch named "test" @@ -2667,7 +2667,7 @@ $ git remote show example # get details next ... $ git fetch example # update branches from example -$ git branch -r # list all remote branches</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="exploring-history"></a>Exploring history</h3></div></div></div><pre class="literallayout">$ gitk # visualize and browse history +$ git branch -r # list all remote branches</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="exploring-history"></a>Exploring history</h2></div></div></div><pre class="literallayout">$ gitk # visualize and browse history $ git log # list all commits $ git log src/ # ...modifying src/ $ git log v2.6.15..v2.6.16 # ...in v2.6.16, not in v2.6.15 @@ -2689,7 +2689,7 @@ Bisecting: 675 revisions left to test after this # test here, then: $ git bisect good # if this revision is good, or $ git bisect bad # if this revision is bad. - # repeat until done.</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="making-changes"></a>Making changes</h3></div></div></div><p>Make sure Git knows who to blame:</p><pre class="literallayout">$ cat >>~/.gitconfig <<\EOF + # repeat until done.</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="making-changes"></a>Making changes</h2></div></div></div><p>Make sure Git knows who to blame:</p><pre class="literallayout">$ cat >>~/.gitconfig <<\EOF [user] name = Your Name Comes Here email = you@yourdomain.example.com @@ -2698,16 +2698,16 @@ commit:</p><pre class="literallayout">$ git add a.txt # updated file $ git add b.txt # new file $ git rm c.txt # old file $ git commit</pre><p>Or, prepare and create the commit in one step:</p><pre class="literallayout">$ git commit d.txt # use latest content only of d.txt -$ git commit -a # use latest content of all tracked files</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="merging"></a>Merging</h3></div></div></div><pre class="literallayout">$ git merge test # merge branch "test" into the current branch +$ git commit -a # use latest content of all tracked files</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="merging"></a>Merging</h2></div></div></div><pre class="literallayout">$ git merge test # merge branch "test" into the current branch $ git pull git://example.com/project.git master # fetch and merge in remote branch -$ git pull . test # equivalent to git merge test</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="sharing-your-changes"></a>Sharing your changes</h3></div></div></div><p>Importing or exporting patches:</p><pre class="literallayout">$ git format-patch origin..HEAD # format a patch for each commit +$ git pull . test # equivalent to git merge test</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sharing-your-changes"></a>Sharing your changes</h2></div></div></div><p>Importing or exporting patches:</p><pre class="literallayout">$ git format-patch origin..HEAD # format a patch for each commit # in HEAD but not in origin $ git am mbox # import patches from the mailbox "mbox"</pre><p>Fetch a branch in a different Git repository, then merge into the current branch:</p><pre class="literallayout">$ git pull git://example.com/project.git theirbranch</pre><p>Store the fetched branch into a local branch before merging into the current branch:</p><pre class="literallayout">$ git pull git://example.com/project.git theirbranch:mybranch</pre><p>After creating commits on a local branch, update the remote branch with your commits:</p><pre class="literallayout">$ git push ssh://example.com/project.git mybranch:theirbranch</pre><p>When remote and local branch are both named "test":</p><pre class="literallayout">$ git push ssh://example.com/project.git test</pre><p>Shortcut version for a frequently used remote repository:</p><pre class="literallayout">$ git remote add example ssh://example.com/project.git -$ git push example test</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="repository-maintenance"></a>Repository maintenance</h3></div></div></div><p>Check for corruption:</p><pre class="literallayout">$ git fsck</pre><p>Recompress, remove unused cruft:</p><pre class="literallayout">$ git gc</pre></div></div><div class="appendix"><h2 class="title" style="clear: both"><a name="todo"></a>B. Notes and todo list for this manual</h2><p>This is a work in progress.</p><p>The basic requirements:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> +$ git push example test</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="repository-maintenance"></a>Repository maintenance</h2></div></div></div><p>Check for corruption:</p><pre class="literallayout">$ git fsck</pre><p>Recompress, remove unused cruft:</p><pre class="literallayout">$ git gc</pre></div></div><div class="appendix"><div class="titlepage"><div><div><h1 class="title"><a name="todo"></a>Appendix B. Notes and todo list for this manual</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="#todo-list">Todo list</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="todo-list"></a>Todo list</h2></div></div></div><p>This is a work in progress.</p><p>The basic requirements:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> It must be readable in order, from beginning to end, by someone intelligent with a basic grasp of the UNIX command line, but without any special knowledge of Git. If necessary, any other prerequisites @@ -2733,4 +2733,4 @@ might be a good idea; maybe make an "advanced examples" section a standard end-of-chapter section?</p><p>Include cross-references to the glossary, where appropriate.</p><p>Add a section on working with other version control systems, including CVS, Subversion, and just imports of series of release tarballs.</p><p>Write a chapter on using plumbing and writing scripts.</p><p>Alternates, clone -reference, etc.</p><p>More on recovery from repository corruption. See: <a class="ulink" href="http://marc.info/?l=git&m=117263864820799&w=2" target="_top">http://marc.info/?l=git&m=117263864820799&w=2</a> - <a class="ulink" href="http://marc.info/?l=git&m=117147855503798&w=2" target="_top">http://marc.info/?l=git&m=117147855503798&w=2</a></p></div></div></body></html> + <a class="ulink" href="http://marc.info/?l=git&m=117147855503798&w=2" target="_top">http://marc.info/?l=git&m=117147855503798&w=2</a></p></div></div></div></body></html> |