Chapter 8. Finding Commits

Part of a good version control system is the support it provides for “archaeology” and investigating a repository. Git provides several mechanisms to help you locate commits that meet certain criteria within your repository.

In this chapter we’ll teach you techniques you can use to find specific commits and their metadata. We’ll focus on three methods you can leverage to search through your repository’s commit history. The first method is very robust and is helpful in locating a single commit satisfying your search criteria. The second method provides information about commits that introduced changes to a file, and the third method uses a specific search variation with the regular git log command.

Besides arming you with search skills in Git when working with commits, this chapter also provides a segue to Chapter 9, where we’ll delve into the topic of altering the commits you found.

Using git bisect

The git bisect command is a powerful tool for isolating a particular commit based on essentially arbitrary search criteria. It is well suited to those times when you discover that something “wrong” or “bad” is affecting your repository and you know the code had been fine. For example, let’s say you are working on the Linux kernel and a test boot fails, but you’re positive the boot worked sometime earlier, perhaps the previous week or at a previous release tag. In this case, your repository has transitioned from a known “good” ...

Get Version Control with Git, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.