You are previewing Pro Git.
O'Reilly logo
Pro Git

Book Description

Programmers or project leaders will learn to use Git, the version control system developed by Linus Torvalds for Linux kernel development. You'll discover the world of distributed version control and learn how to build a Git development workflow, with expert guidance from Scott Chacon.

Table of Contents

  1. Copyright
  2. Foreword
  3. About the Author
  4. About the Technical Reviewer
  5. Acknowledgments
  6. Introduction
  7. 1. Getting Started
    1. 1.1. About Version Control
    2. 1.2. Local Version Control Systems
    3. 1.3. Centralized Version Control Systems
    4. 1.4. Distributed Version Control Systems
    5. 1.5. A Short History of Git
    6. 1.6. Git Basics
      1. 1.6.1. Snapshots, Not Differences
      2. 1.6.2. Nearly Every Operation Is Local
      3. 1.6.3. Git Has Integrity
      4. 1.6.4. Git Generally Only Adds Data
      5. 1.6.5. The Three States
    7. 1.7. Installing Git
      1. 1.7.1. Installing from Source
      2. 1.7.2. Installing on Linux
      3. 1.7.3. Installing on Mac
      4. 1.7.4. Installing on Windows
    8. 1.8. First-Time Git Setup
      1. 1.8.1. Your Identity
      2. 1.8.2. Your Editor
      3. 1.8.3. Your Diff Tool
      4. 1.8.4. Checking Your Settings
    9. 1.9. Getting Help
    10. 1.10. Summary
  8. 2. Git Basics
    1. 2.1. Getting a Git Repository
      1. 2.1.1. Initializing a Repository in an Existing Directory
      2. 2.1.2. Cloning an Existing Repository
    2. 2.2. Recording Changes to the Repository
      1. 2.2.1. Checking the Status of Your Files
      2. 2.2.2. Tracking New Files
      3. 2.2.3. Staging Modified Files
      4. 2.2.4. Ignoring Files
      5. 2.2.5. Viewing Your Staged and Unstaged Changes
      6. 2.2.6. Committing Your Changes
      7. 2.2.7. Skipping the Staging Area
      8. 2.2.8. Removing Files
      9. 2.2.9. Moving Files
    3. 2.3. Viewing the Commit History
      1. 2.3.1. Limiting Log Output
      2. 2.3.2. Using a GUI to Visualize History
    4. 2.4. Undoing Things
      1. 2.4.1. Changing Your Last Commit
      2. 2.4.2. Unstaging a Staged File
      3. 2.4.3. Unmodifying a Modified File
    5. 2.5. Working with Remotes
      1. 2.5.1. Showing Your Remotes
      2. 2.5.2. Adding Remote Repositories
      3. 2.5.3. Fetching and Pulling from Your Remotes
      4. 2.5.4. Pushing to Your Remotes
      5. 2.5.5. Inspecting a Remote
      6. 2.5.6. Removing and Renaming Remotes
    6. 2.6. Tagging
      1. 2.6.1. Listing Your Tags
      2. 2.6.2. Creating Tags
        1. 2.6.2.1. Annotated Tags
        2. 2.6.2.2. Signed Tags
        3. 2.6.2.3. Lightweight Tags
      3. 2.6.3. Verifying Tags
      4. 2.6.4. Tagging Later
      5. 2.6.5. Sharing Tags
    7. 2.7. Tips and Tricks
      1. 2.7.1. Auto-Completion
      2. 2.7.2. Git Aliases
    8. 2.8. Summary
  9. 3. Git Branching
    1. 3.1. What a Branch Is
    2. 3.2. Basic Branching and Merging
      1. 3.2.1. Basic Branching
      2. 3.2.2. Basic Merging
      3. 3.2.3. Basic Merge Conflicts
    3. 3.3. Branch Management
    4. 3.4. Branching Workflows
      1. 3.4.1. Long-Running Branches
      2. 3.4.2. Topic Branches
    5. 3.5. Remote Branches
      1. 3.5.1. Pushing
      2. 3.5.2. Tracking Branches
      3. 3.5.3. Deleting Remote Branches
    6. 3.6. Rebasing
      1. 3.6.1. The Basic Rebase
      2. 3.6.2. More Interesting Rebases
      3. 3.6.3. The Perils of Rebasing
    7. 3.7. Summary
  10. 4. Git on the Server
    1. 4.1. The Protocols
      1. 4.1.1. Local Protocol
        1. 4.1.1.1. The Pros
        2. 4.1.1.2. The Cons
      2. 4.1.2. The SSH Protocol
        1. 4.1.2.1. The Pros
        2. 4.1.2.2. The Cons
      3. 4.1.3. The Git Protocol
        1. 4.1.3.1. The Pros
        2. 4.1.3.2. The Cons
      4. 4.1.4. The HTTP/S Protocol
        1. 4.1.4.1. The Pros
        2. 4.1.4.2. The Cons
    2. 4.2. Getting Git on a Server
      1. 4.2.1. Putting the Bare Repository on a Server
    3. 4.3. Small Setups
      1. 4.3.1. SSH Access
      2. 4.3.2. Generating Your SSH Public Key
      3. 4.3.3. Setting Up the Server
      4. 4.3.4. Public Access
      5. 4.3.5. GitWeb
    4. 4.4. Gitosis
      1. 4.4.1. Git Daemon
    5. 4.5. Hosted Git
      1. 4.5.1. GitHub
      2. 4.5.2. Setting Up a User Account
      3. 4.5.3. Creating a New Repository
      4. 4.5.4. Importing from Subversion
      5. 4.5.5. Adding Collaborators
      6. 4.5.6. Your Project
      7. 4.5.7. Forking Projects
      8. 4.5.8. GitHub Summary
    6. 4.6. Summary
  11. 5. Distributed Git
    1. 5.1. Distributed Workflows
      1. 5.1.1. Centralized Workflow
      2. 5.1.2. Integration-Manager Workflow
      3. 5.1.3. Dictator and Lieutenants Workflow
    2. 5.2. Contributing to a Project
      1. 5.2.1. Commit Guidelines
      2. 5.2.2. Private Small Team
      3. 5.2.3. Private Managed Team
      4. 5.2.4. Public Small Project
      5. 5.2.5. Public Large Project
      6. 5.2.6. Summary
    3. 5.3. Maintaining a Project
      1. 5.3.1. Working in Topic Branches
      2. 5.3.2. Applying Patches from E-mail
        1. 5.3.2.1. Applying a Patch with apply
        2. 5.3.2.2. Applying a Patch with am
      3. 5.3.3. Checking Out Remote Branches
      4. 5.3.4. Determining What Is Introduced
      5. 5.3.5. Integrating Contributed Work
        1. 5.3.5.1. Merging Workflows
        2. 5.3.5.2. Large-Merging Workflows
        3. 5.3.5.3. Rebasing and Cherry-Picking Workflows
      6. 5.3.6. Tagging Your Releases
      7. 5.3.7. Generating a Build Number
      8. 5.3.8. Preparing a Release
      9. 5.3.9. The Shortlog
    4. 5.4. Summary
  12. 6. Git Tools
    1. 6.1. Revision Selection
      1. 6.1.1. Single Revisions
        1. 6.1.1.1. Short SHA
        2. 6.1.1.2. Branch References
        3. 6.1.1.3. RefLog Shortnames
        4. 6.1.1.4. Ancestry References
      2. 6.1.2. Commit Ranges
        1. 6.1.2.1. Double Dot
        2. 6.1.2.2. Multiple Points
        3. 6.1.2.3. Triple Dot
    2. 6.2. Interactive Staging
      1. 6.2.1.
        1. 6.2.1.1. Staging and Unstaging Files
        2. 6.2.1.2. Staging Patches
    3. 6.3. Stashing
      1. 6.3.1. Stashing Your Work
      2. 6.3.2. Creating a Branch from a Stash
    4. 6.4. Rewriting History
      1. 6.4.1. Changing the Last Commit
      2. 6.4.2. Changing Multiple Commit Messages
      3. 6.4.3. Reordering Commits
      4. 6.4.4. Squashing a Commit
      5. 6.4.5. Splitting a Commit
      6. 6.4.6. The Nuclear Option: filter-branch
        1. 6.4.6.1. Removing a File from Every Commit
        2. 6.4.6.2. Making a Subdirectory the New Root
        3. 6.4.6.3. Changing E-mail Addresses Globally
    5. 6.5. Debugging with Git
      1. 6.5.1. File Annotation
      2. 6.5.2. Binary Search
    6. 6.6. Submodules
      1. 6.6.1. Starting with Submodules
      2. 6.6.2. Cloning a Project with Submodules
      3. 6.6.3. Superprojects
      4. 6.6.4. Issues with Submodules
    7. 6.7. Subtree Merging
    8. 6.8. Summary
  13. 7. Customizing Git
    1. 7.1. Git Configuration
      1. 7.1.1. Basic Client Configuration
        1. 7.1.1.1. core.editor
        2. 7.1.1.2. commit.template
        3. 7.1.1.3. core.pager
        4. 7.1.1.4. user.signingkey
        5. 7.1.1.5. core.excludesfile
        6. 7.1.1.6. help.autocorrect
      2. 7.1.2. Colors in Git
        1. 7.1.2.1. color.ui
        2. 7.1.2.2. color.*
      3. 7.1.3. External Merge and Diff Tools
      4. 7.1.4. Formatting and Whitespace
        1. 7.1.4.1. core.autocrlf
        2. 7.1.4.2. core.whitespace
      5. 7.1.5. Server Configuration
        1. 7.1.5.1. receive.fsckObjects
        2. 7.1.5.2. receive.denyNonFastForwards
        3. 7.1.5.3. receive.denyDeletes
    2. 7.2. Git Attributes
      1. 7.2.1. Binary Files
        1. 7.2.1.1. Identifying Binary Files
        2. 7.2.1.2. Diffing Binary Files
      2. 7.2.2. Keyword Expansion
      3. 7.2.3. Exporting Your Repository
        1. 7.2.3.1. export-ignore
        2. 7.2.3.2. export-subst
      4. 7.2.4. Merge Strategies
    3. 7.3. Git Hooks
      1. 7.3.1. Installing a Hook
      2. 7.3.2. Client-Side Hooks
        1. 7.3.2.1. Committing-Workflow Hooks
        2. 7.3.2.2. E-mail Workflow Hooks
        3. 7.3.2.3. Other Client Hooks
      3. 7.3.3. Server-Side Hooks
        1. 7.3.3.1. pre-receive and post-receive
        2. 7.3.3.2. update
    4. 7.4. An Example Git-Enforced Policy
      1. 7.4.1. Server-Side Hook
        1. 7.4.1.1. Enforcing a Specific Commit-Message Format
        2. 7.4.1.2. Enforcing a User-Based ACL System
        3. 7.4.1.3. Enforcing Fast-Forward-Only Pushes
      2. 7.4.2. Client-Side Hooks
    5. 7.5. Summary
  14. 8. Git and Other Systems
    1. 8.1. Git and Subversion
      1. 8.1.1. git svn
      2. 8.1.2. Setting Up
      3. 8.1.3. Getting Started
      4. 8.1.4. Committing Back to Subversion
      5. 8.1.5. Pulling in New Changes
      6. 8.1.6. Git Branching Issues
      7. 8.1.7. Subversion Branching
        1. 8.1.7.1. Creating a New SVN Branch
        2. 8.1.7.2. Switching Active Branches
      8. 8.1.8. Subversion Commands
        1. 8.1.8.1. SVN Style History
        2. 8.1.8.2. SVN Annotation
      9. 8.1.9. SVN Server Information
        1. 8.1.9.1. Ignoring What Subversion Ignores
      10. 8.1.10. Git-Svn Summary
    2. 8.2. Migrating to Git
      1. 8.2.1. Importing
        1. 8.2.1.1. Subversion
      2. 8.2.2. Perforce
      3. 8.2.3. A Custom Importer
      4. 8.2.4. Summary
  15. 9. Git Internals
    1. 9.1. Plumbing and Porcelain
    2. 9.2. Git Objects
      1. 9.2.1. Tree Objects
      2. 9.2.2. Commit Objects
      3. 9.2.3. Object Storage
    3. 9.3. Git References
      1. 9.3.1. The HEAD
      2. 9.3.2. Tags
      3. 9.3.3. Remotes
    4. 9.4. Packfiles
      1. 9.4.1. The Refspec
      2. 9.4.2. Pushing Refspecs
      3. 9.4.3. Deleting References
    5. 9.5. Transfer Protocols
      1. 9.5.1. The Dumb Protocol
      2. 9.5.2. The Smart Protocol
        1. 9.5.2.1. Uploading Data
      3. 9.5.3. Downloading Data
    6. 9.6. Maintenance and Data Recovery
      1. 9.6.1. Maintenance
      2. 9.6.2. Data Recovery
      3. 9.6.3. Removing Objects
    7. 9.7. Summary
  16. A. Creative Commons Legal Code
    1. A.1. Attribution-NonCommercial-ShareAlike 3.0 Unported
    2. A.2. License
    3. A.3. Creative Commons Notice