You are previewing Pro Git, Second Edition.
O'Reilly logo
Pro Git, Second Edition

Book Description

Pro Git (Second Edition) is your fully-updated guide to Git and its usage in the modern world. Git has come a long way since it was first developed by Linus Torvalds for Linux kernel development. It has taken the open source world by storm since its inception in 2005, and this book teaches you how to use it like a pro.

Effective and well-implemented version control is a necessity for successful web projects, whether large or small. With this book you’ll learn how to master the world of distributed version workflow, use the distributed features of Git to the full, and extend Git to meet your every need.

Written by Git pros Scott Chacon and Ben Straub, Pro Git (Second Edition) builds on the hugely successful first edition, and is now fully updated for Git version 2.0, as well as including an indispensable chapter on GitHub. It’s the best book for all your Git needs.

Table of Contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Authors
  8. Preface by Scott Chacon
  9. Preface by Ben Straub
  10. Chapter 1: Getting Started
    1. About Version Control
      1. Local Version Control Systems
      2. Centralized Version Control Systems
      3. Distributed Version Control Systems
    2. A Short History of Git
    3. Git Basics
      1. Snapshots, Not Differences
      2. Nearly Every Operation Is Local
      3. Git Has Integrity
      4. Git Generally Only Adds Data
      5. The Three States
    4. The Command Line
    5. Installing Git
      1. Installing on Linux
      2. Installing on Mac
      3. Installing on Windows
    6. First-Time Git Setup
      1. Your Identity
      2. Your Editor
      3. Checking Your Settings
    7. Getting Help
    8. Summary
  11. Chapter 2: Git Basics
    1. Getting a Git Repository
      1. Initializing a Repository in an Existing Directory
      2. Cloning an Existing Repository
    2. Recording Changes to the Repository
      1. Checking the Status of Your Files
      2. Tracking New Files
      3. Staging Modified Files
      4. Short Status
      5. Ignoring Files
      6. Viewing Your Staged and Unstaged Changes
      7. Committing Your Changes
      8. Skipping the Staging Area
      9. Removing Files
      10. Moving Files
    3. Viewing the Commit History
      1. Limiting Log Output
    4. Undoing Things
      1. Unstaging a Staged File
      2. Unmodifying a Modified File
    5. Working with Remotes
      1. Showing Your Remotes
      2. Adding Remote Repositories
      3. Fetching and Pulling from Your Remotes
      4. Pushing to Your Remotes
      5. Inspecting a Remote
      6. Removing and Renaming Remotes
    6. Tagging
      1. Listing Your Tags
      2. Creating Tags
      3. Annotated Tags
      4. Lightweight Tags
      5. Tagging Later
      6. Sharing Tags
    7. Git Aliases
    8. Summary
  12. Chapter 3: Git Branching
    1. Branching in a Nutshell
      1. Creating a New Branch
      2. Switching Branches
    2. Basic Branching and Merging
      1. Basic Branching
      2. Basic Merging
      3. Basic Merge Conflicts
    3. Branch Management
    4. Branching Workflows
      1. Long-Running Branches
      2. Topic Branches
    5. Remote Branches
      1. Pushing
      2. Tracking Branches
      3. Pulling
      4. Deleting Remote Branches
    6. Rebasing
      1. The Basic Rebase
      2. More Interesting Rebases
      3. The Perils of Rebasing
      4. Rebase When You Rebase
      5. Rebase vs. Merge
    7. Summary
  13. Chapter 4: Git on the Server
    1. The Protocols
      1. Local Protocol
      2. The HTTP Protocols
      3. The Git Protocol
    2. Getting Git on a Server
      1. Putting the Bare Repository on a Server
      2. Small Setups
    3. Generating Your SSH Public Key
    4. Setting Up the Server
    5. Git Daemon
    6. Smart HTTP
    7. GitWeb
    8. GitLab
      1. Installation
      2. Administration
      3. Users
      4. Groups
      5. Projects
      6. Hooks
      7. Basic Usage
      8. Working Together
    9. Third Party Hosted Options
    10. Summary
  14. Chapter 5: Distributed Git
    1. Distributed Workflows
      1. Centralized Workflow
      2. Integration-Manager Workflow
      3. Dictator and Lieutenants Workflow
      4. Workf lows Summary
    2. Contributing to a Project
      1. Commit Guidelines
      2. Private Small Team
      3. Private Managed Team
      4. Public Project, Fork
      5. Public Project, E-Mail
      6. Summary
    3. Maintaining a Project
      1. Working in Topic Branches
      2. Applying Patches from E-mail
      3. Determining What Is Introduced
      4. Integrating Contributed Work
      5. Large-Merging Workflows
      6. Rebasing and Cherry Picking Workflows
      7. Rerere
      8. Tagging Your Releases
      9. Generating a Build Number
      10. Preparing a Release
      11. The Shortlog
    4. Summary
  15. Chapter 6: Github
    1. Account Setup and Configuration
      1. SSH Access
      2. Your Avatar
      3. Your Email Addresses
      4. Two-Factor Authentication
    2. Contributing to a Project
      1. Forking Projects
      2. The GitHub Flow
      3. Creating a Pull Request
      4. Iterating on a Pull Request
      5. Advanced Pull Requests
      6. Markdown
      7. GitHub Flavored Markdown
    3. Maintaining a Project
      1. Creating a New Repository
      2. Adding Collaborators
      3. Managing Pull Requests
      4. Mentions and Notifications
      5. Special Files
      6. Project Administration
    4. Managing an Organization
      1. Organization Basics
      2. Teams
      3. Audit Log
    5. Scripting GitHub
      1. Hooks
      2. The GitHub API
      3. Octokit
    6. Summary
  16. Chapter 7: Git Tools
    1. Revision Selection
      1. Single Revisions
      2. Short SHA
      3. Branch References
      4. Ref?Log Shortnames
      5. Ancestry References
      6. Commit Ranges
    2. Interactive Staging
      1. Staging and Unstaging Files
      2. Staging Patches
    3. Stashing and Cleaning
      1. Stashing Your Work
      2. Creative Stashing
      3. Unapplying a Stash
      4. Creating a Branch from a Stash
      5. Cleaning Your Working Directory
    4. Signing Your Work
      1. GPG Introduction
      2. Signing Tags
      3. Verifying Tags
      4. Signing Commits
      5. Everyone Must Sign
    5. Searching
      1. Git Grep
      2. Git Log Searching
      3. Line Log Search
    6. Rewriting History
      1. Changing the Last Commit
      2. Changing Multiple Commit Messages
      3. Reordering Commits
      4. Squashing a Commit
      5. Splitting a Commit
      6. The Nuclear Option: filter-branch
    7. Reset Demystified
      1. The Three Trees
      2. The Workflow
      3. The Role of Reset
      4. Reset with a Path
      5. Squashing
      6. Check It Out
      7. Summary
    8. Advanced Merging
      1. Merge Conflicts
      2. Aborting a Merge
      3. Ignoring Whitespace
      4. Manual File Re-merging
      5. Checking Out Conflicts
      6. Merge Log
      7. Combined Diff Format
      8. Undoing Merges
      9. Other Types of Merges
    9. Rerere
    10. Debugging with Git
      1. File Annotation
      2. Binary Search
    11. Submodules
      1. Starting with Submodules
      2. Cloning a Project with Submodules
      3. Working on a Project with Submodules
      4. Publishing Submodule Changes
      5. Merging Submodule Changes
      6. Submodule Tips
      7. Bundling
    12. Replace
    13. Credential Storage
      1. Under the Hood
      2. A Custom Credential Cache
    14. Summary
  17. Chapter 8: Customizing Git
    1. Git Configuration
      1. Basic Client Configuration
      2. Colors in Git
      3. External Merge and Diff Tools
      4. Formatting and Whitespace
      5. Server Configuration
    2. Git Attributes
      1. Binary Files
      2. Keyword Expansion
      3. Exporting Your Repository
      4. Merge Strategies
    3. Git Hooks
      1. Installing a Hook
      2. Client-Side Hooks
      3. Committing-Workflow Hooks
      4. E-mail Workflow Hooks
      5. Other Client Hooks
      6. Server-Side Hooks
    4. An Example Git-Enforced Policy
      1. Server-Side Hook
      2. Enforcing a Specific Commit-Message Format
      3. Enforcing a User-Based ACL System
      4. Testing It Out
      5. Client-Side Hooks
    5. Summary
  18. Chapter 9: Git and Other Systems
    1. Git as a Client
      1. Git and Subversion
      2. Git and Mercurial
      3. Git and Perforce
      4. Git and TFS
    2. Migrating to Git
      1. Subversion
      2. Mercurial
      3. Perforce
      4. A Custom Importer
    3. Summary
  19. Chapter 10: Git Internals
    1. Plumbing and Porcelain
    2. Git Objects
      1. Tree Objects
      2. Commit Objects
      3. Object Storage
    3. Git References
      1. The HEAD
      2. Tags
      3. Remotes
    4. Packfiles
    5. The Refspec
      1. Pushing Refspecs
      2. Deleting References
    6. Transfer Protocols
      1. The Dumb Protocol
      2. The Smart Protocol
      3. Protocols Summary
    7. Maintenance and Data Recovery
      1. Maintenance
      2. Data Recovery
      3. Removing Objects
    8. Environment Variables
      1. Global Behavior
      2. Repository Locations
      3. Pathspecs
      4. Committing
      5. Networking
      6. Diffing and Merging
      7. Debugging
      8. Miscellaneous
    9. Summary
  20. Appendix A: Git in Other Environments
    1. Graphical Interfaces
      1. gitk and git-gui
      2. GitHub for Mac and Windows
      3. Summary
    2. Other GUIs
    3. Git in Visual Studio
    4. Git in Eclipse
    5. Git in Bash
    6. Git in Zsh
    7. Git in Powershell
    8. Summary
  21. Appendix B: Embedded Git in Your Applications
    1. Command-line Git
    2. Libgit2
      1. Advanced Functionality
      2. Other Bindings
      3. Further Reading
  22. Appendix C: Git Commands
    1. Setup and Config
      1. git config
      2. git help
    2. Getting and Creating Projects
      1. git init
      2. git clone
    3. Basic Snapshotting
      1. git add
      2. git status
      3. git diff
      4. git difftool
      5. git commit
      6. git reset
      7. git rm
      8. git mv
      9. git clean
    4. Branching and Merging
      1. git branch
      2. git checkout
      3. git merge
      4. git mergetool
      5. git log
      6. git stash
      7. git tag
    5. Sharing and Updating Projects
      1. git fetch
      2. git pull
      3. git push
      4. git remote
      5. git archive
      6. git submodule
    6. Inspection and Comparison
      1. git show
      2. git shortlog
      3. git describe
    7. Debugging
      1. git bisect
      2. git blame
      3. git grep
    8. Patching
      1. git cherry-pick
      2. git rebase
      3. git revert
    9. Email
      1. git apply
      2. git am
      3. git format-patch
      4. git send-email
      5. git request-pull
    10. External Systems
      1. git svn
      2. git fast-import
    11. Administration
      1. git gc
      2. git fsck
      3. git reflog
      4. git filter-branch
    12. Plumbing Commands
  23. Index