Contents
1 Getting Started 1
1.1 About Version Control . . . . . . . . . . . . . . . . . . . . . 11.1.1 Local Version Control Systems . . . . . . . . . . . . 11.1.2 Centralized Version Control Systems . . . . . . . . 21.1.3 Distributed Version Control Systems . . . . . . . . 31.2 A Short History of Git . . . . . . . . . . . . . . . . . . . . . 31.3 Git Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.3.1 Snapshots, Not Differences . . . . . . . . . . . . . . 51.3.2 Nearly Every Operation Is Local . . . . . . . . . . . 61.3.3 Git Has Integrity . . . . . . . . . . . . . . . . . . . . 71.3.4 Git Generally Only Adds Data . . . . . . . . . . . . . 71.3.5 The Three States . . . . . . . . . . . . . . . . . . . . 71.4 Installing Git . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.4.1 Installing from Source . . . . . . . . . . . . . . . . . 91.4.2 Installing on Linux . . . . . . . . . . . . . . . . . . . 91.4.3 Installing on Mac . . . . . . . . . . . . . . . . . . . . 101.4.4 Installing on Windows . . . . . . . . . . . . . . . . . 101.5 First-Time Git Setup . . . . . . . . . . . . . . . . . . . . . . 111.5.1 Your Identity . . . . . . . . . . . . . . . . . . . . . . . 111.5.2 Your Editor . . . . . . . . . . . . . . . . . . . . . . . . 111.5.3 Your Diff Tool . . . . . . . . . . . . . . . . . . . . . . . 121.5.4 Checking Your Settings . . . . . . . . . . . . . . . . 121.6 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 Git Basics 15
2.1 Getting a Git Repository . . . . . . . . . . . . . . . . . . . . 152.1.1 Initializing a Repository in an Existing Directory . 152.1.2 Cloning an Existing Repository . . . . . . . . . . . . 162.2 Recording Changes to the Repository . . . . . . . . . . . . 162.2.1 Checking the Status of Your Files . . . . . . . . . . 172.2.2 Tracking New Files . . . . . . . . . . . . . . . . . . . 182.2.3 Staging Modified Files . . . . . . . . . . . . . . . . . 182.2.4 Ignoring Files . . . . . . . . . . . . . . . . . . . . . . 202.2.5 Viewing Your Staged and Unstaged Changes . . . 212.2.6 Committing Your Changes . . . . . . . . . . . . . . . 232.2.7 Skipping the Staging Area . . . . . . . . . . . . . . . 24
iii