CONTENTS 3
Contents
Preface71 Repositories and Branches7
1.1 How to get a git repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.2 How to check out a different version of a project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.3 Understanding History: Commits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.3.1 Understanding history: commits, parents, and reachability. . . . . . . . . . . . . . . . . . . . . . 91.3.2 Understanding history: History diagrams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.3.3 Understanding history: What is a branch?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.4 Manipulating branches. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.5 Examining an old version without creating a new branch. . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.6 Examining branches from a remote repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.7 Naming branches, tags, and other references. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.8 Updating a repository with git fetch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.9 Fetching branches from other repositories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 Exploring git history12
2.1 How to use bisect to find a regression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.2 Naming commits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.3 Creating tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.4 Browsing revisions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.5 Generating diffs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.6 Viewing old file versions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.7 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.7.1 Counting the number of commits on a branch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.7.2 Check whether two branches point at the same history. . . . . . . . . . . . . . . . . . . . . . . . 162.7.3 Find first tagged version including a given fix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.7.4 Showing commits unique to a given branch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.7.5 Creating a changelog and tarball for a software release. . . . . . . . . . . . . . . . . . . . . . . 182.7.6 Finding commits referencing a file with given content. . . . . . . . . . . . . . . . . . . . . . . . . 19
3 Developing with git19
3.1 Telling git your name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.2 Creating a new repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.3 How to make a commit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.4 Creating good commit messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.5 Ignoring files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.6 How to merge. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.7 Resolving a merge. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.7.1 Getting conflict-resolution help during a merge. . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.8 Undoing a merge. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.9 Fast-forward merges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.10 Fixing mistakes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.10.1 Fixing a mistake with a new commit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.10.2 Fixing a mistake by rewriting history. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.10.3 Checking out an old version of a file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.10.4 Temporarily setting aside work in progress. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.11 Ensuring good performance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.12 Ensuring reliability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.12.1 Checking the repository for corruption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26v1.5.3 or newer Git User’s Manual
Leave a Comment