Version Control with Git( 2nd Edition)
Get up to speed on Git for tracking, branching, merging, and managing code revisions. Through a series of step-by-step tutorials, this practical guide takes you quickly from Git fundamentals to advanced techniques, and provides friendly yet rigorous advice for navigating the many functions of this open source version control system.
This thoroughly revised edition also includes tips for manipulating trees, extended coverage of the reflog and stash, and a complete introduction to the GitHub repository. Git lets you manage code development in a virtually endless variety of ways, once you understand how to harness the system’s flexibility. This book shows you how.
Learn how to use Git for several real-world development scenarios
Gain insight into Git’s common-use cases, initial tasks, and basic functions
Use the system for both centralized and distributed version control
Learn how to manage merges, conflicts, patches, and diffs
Apply advanced techniques such as rebasing, hooks, and ways to handle submodules
Interact with Subversion (SVN) repositories—including SVN to Git conversions
Navigate, use, and contribute to open source projects though GitHub
Table of contents
Chapter 1 Introduction
Background
The Birth of Git
Precedents
Timeline
What’s in a Name?
Chapter 2 Installing Git
Using Linux Binary Distributions
Obtaining a Source Release
Building and Installing
Installing Git on Windows
Chapter 3 Getting Started
The Git Command Line
Quick Introduction to Using Git
Configuration Files
Inquiry
Chapter 4 Basic Git Concepts
Basic Concepts
Object Store Pictures
Git Concepts at Work
Chapter 5 File Management and the Index
It’s All About the Index
File Classifications in Git
Using git add
Some Notes on Using git commit
Using git rm
Using git mv
A Note on Tracking Renames
The .gitignore File
A Detailed View of Git’s Object Model and Files
Chapter 6 Commits
Atomic Changesets
Identifying Commits
Commit History
Finding Commits
Chapter 7 Branches
Reasons for Using Branches
Branch Names
Using Branches
Creating Branches
Listing Branch Names
Viewing Branches
Checking out Branches
Deleting Branches
Chapter 8 Diffs
Forms of the git diff Command
Simple git diff Example
git diff and Commit Ranges
git diff with Path Limiting
Comparing How Subversion and Git Derive diffs
Chapter 9 Merges
Merge Examples
Working with Merge Conflicts
Merge Strategies
How Git Thinks About Merges
Chapter 10 Altering Commits
Caution About Altering History
Using git reset
Using git cherry-pick
Using git revert
reset, revert, and checkout
Changing the Top Commit
Rebasing Commits
Chapter 11 The Stash and the Reflog
The Stash
The Reflog
Chapter 12 Remote Repositories
Repository Concepts
Referencing Other Repositories
Example Using Remote Repositories
Remote Repository Development Cycle in Pictures
Remote Configuration
Working with Tracking Branches
Adding and Deleting Remote Branches
Bare Repositories and git push
Chapter 13 Repository Management
A Word About Servers
Publishing Repositories
Repository Publishing Advice
Repository Structure
Living with Distributed Development
Knowing Your Place
Working with Multiple Repositories
Chapter 14 Patches
Why Use Patches?
Generating Patches
Mailing Patches
Applying Patches
Bad Patches
Patching Versus Merging
Chapter 15 Hooks
Installing Hooks
Available Hooks
Chapter 16 Combining Projects
The Old Solution: Partial Checkouts
The Obvious Solution: Import the Code into Your Project
The Automated Solution: Checking out Subprojects Using Custom Scripts
The Native Solution: gitlinks and git submodule
Chapter 17 Submodule Best Practices
Submodule Commands
Why Submodules?
Submodules Preparation
Why Read Only?
Why Not Read Only?
Examining the Hashes of Submodule Commits
Credential Reuse
Use Cases
Multilevel Nesting of Repos
Submodules on the Horizon
Chapter 18 Using Git with Subversion Repositories
Example: A Shallow Clone of a Single Branch
Pushing, Pulling, Branching, and Merging with git svn
Miscellaneous Notes on Working with Subversion
Chapter 19 Advanced Manipulations
Using git filter-branch
How I Learned to Love git rev-list
Interactive Hunk Staging
Recovering a Lost Commit
Chapter 20 Tips, Tricks, and Techniques
Interactive Rebase with a Dirty Working Directory
Remove Left-Over Editor Files
Garbage Collection
Split a Repository
Tips for Recovering Commits
Subversion Conversion Tips
Manipulating Branches from Two Repositories
Recovering from an Upstream Rebase
Make Your Own Git Command
Quick Overview of Changes
Cleaning Up
Using git-grep to Search a Repository
Updating and Deleting refs
Following Files that Moved
Keep, But Don’t Track, This File
Have You Been Here Before?
Chapter 21 Git and GitHub
Repo for Public Code
Creating a GitHub Repository
Social Coding on Open Source
Watchers
News Feed
Forks
Creating Pull Requests
Managing Pull Requests
Notifications
Finding Users, Projects, and Code
Wikis
GitHub Pages (Git for Websites)
In-Page Code Editor
Subversion Bridge
Tags Automatically Becoming Archives
Organizations
REST API
Social Coding on Closed Source
Eventual Open Sourcing
Coding Models
GitHub Enterprise
GitHub in Sum
This thoroughly revised edition also includes tips for manipulating trees, extended coverage of the reflog and stash, and a complete introduction to the GitHub repository. Git lets you manage code development in a virtually endless variety of ways, once you understand how to harness the system’s flexibility. This book shows you how.
Learn how to use Git for several real-world development scenarios
Gain insight into Git’s common-use cases, initial tasks, and basic functions
Use the system for both centralized and distributed version control
Learn how to manage merges, conflicts, patches, and diffs
Apply advanced techniques such as rebasing, hooks, and ways to handle submodules
Interact with Subversion (SVN) repositories—including SVN to Git conversions
Navigate, use, and contribute to open source projects though GitHub
Table of contents
Chapter 1 Introduction
Background
The Birth of Git
Precedents
Timeline
What’s in a Name?
Chapter 2 Installing Git
Using Linux Binary Distributions
Obtaining a Source Release
Building and Installing
Installing Git on Windows
Chapter 3 Getting Started
The Git Command Line
Quick Introduction to Using Git
Configuration Files
Inquiry
Chapter 4 Basic Git Concepts
Basic Concepts
Object Store Pictures
Git Concepts at Work
Chapter 5 File Management and the Index
It’s All About the Index
File Classifications in Git
Using git add
Some Notes on Using git commit
Using git rm
Using git mv
A Note on Tracking Renames
The .gitignore File
A Detailed View of Git’s Object Model and Files
Chapter 6 Commits
Atomic Changesets
Identifying Commits
Commit History
Finding Commits
Chapter 7 Branches
Reasons for Using Branches
Branch Names
Using Branches
Creating Branches
Listing Branch Names
Viewing Branches
Checking out Branches
Deleting Branches
Chapter 8 Diffs
Forms of the git diff Command
Simple git diff Example
git diff and Commit Ranges
git diff with Path Limiting
Comparing How Subversion and Git Derive diffs
Chapter 9 Merges
Merge Examples
Working with Merge Conflicts
Merge Strategies
How Git Thinks About Merges
Chapter 10 Altering Commits
Caution About Altering History
Using git reset
Using git cherry-pick
Using git revert
reset, revert, and checkout
Changing the Top Commit
Rebasing Commits
Chapter 11 The Stash and the Reflog
The Stash
The Reflog
Chapter 12 Remote Repositories
Repository Concepts
Referencing Other Repositories
Example Using Remote Repositories
Remote Repository Development Cycle in Pictures
Remote Configuration
Working with Tracking Branches
Adding and Deleting Remote Branches
Bare Repositories and git push
Chapter 13 Repository Management
A Word About Servers
Publishing Repositories
Repository Publishing Advice
Repository Structure
Living with Distributed Development
Knowing Your Place
Working with Multiple Repositories
Chapter 14 Patches
Why Use Patches?
Generating Patches
Mailing Patches
Applying Patches
Bad Patches
Patching Versus Merging
Chapter 15 Hooks
Installing Hooks
Available Hooks
Chapter 16 Combining Projects
The Old Solution: Partial Checkouts
The Obvious Solution: Import the Code into Your Project
The Automated Solution: Checking out Subprojects Using Custom Scripts
The Native Solution: gitlinks and git submodule
Chapter 17 Submodule Best Practices
Submodule Commands
Why Submodules?
Submodules Preparation
Why Read Only?
Why Not Read Only?
Examining the Hashes of Submodule Commits
Credential Reuse
Use Cases
Multilevel Nesting of Repos
Submodules on the Horizon
Chapter 18 Using Git with Subversion Repositories
Example: A Shallow Clone of a Single Branch
Pushing, Pulling, Branching, and Merging with git svn
Miscellaneous Notes on Working with Subversion
Chapter 19 Advanced Manipulations
Using git filter-branch
How I Learned to Love git rev-list
Interactive Hunk Staging
Recovering a Lost Commit
Chapter 20 Tips, Tricks, and Techniques
Interactive Rebase with a Dirty Working Directory
Remove Left-Over Editor Files
Garbage Collection
Split a Repository
Tips for Recovering Commits
Subversion Conversion Tips
Manipulating Branches from Two Repositories
Recovering from an Upstream Rebase
Make Your Own Git Command
Quick Overview of Changes
Cleaning Up
Using git-grep to Search a Repository
Updating and Deleting refs
Following Files that Moved
Keep, But Don’t Track, This File
Have You Been Here Before?
Chapter 21 Git and GitHub
Repo for Public Code
Creating a GitHub Repository
Social Coding on Open Source
Watchers
News Feed
Forks
Creating Pull Requests
Managing Pull Requests
Notifications
Finding Users, Projects, and Code
Wikis
GitHub Pages (Git for Websites)
In-Page Code Editor
Subversion Bridge
Tags Automatically Becoming Archives
Organizations
REST API
Social Coding on Closed Source
Eventual Open Sourcing
Coding Models
GitHub Enterprise
GitHub in Sum
Top rated books in this category