Finding Commits
Part of a good revision 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.
Using git bisect
The git bisect command is a powerful tool for isolating a particular, faulty commit based on essentially arbitrary search criteria. git bisect is well suited to those times when you discover that something âwrongâ or âbadâ is affecting your repository and you know the code used to be 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 last week or at a previous release tag. In this case, your repository has transitioned from a known âgoodâ state to a known âbadâ state.
But when? Which commit caused it to break? That is precisely the question git bisect is designed to help you answer.
The only real search requirement is that, given a checked-out state of your repository, you are able to determine if it does or does not meet your search requirement. In this case, you have to be able to answer the question, âDoes the version of the kernel checked out build and boot?â You also have to know a âgoodâ and a âbadâ version or commit before starting so that the search will be bounded.
git bisect is often used to isolate a particular commit that introduced some regression or bug into the repository. For example, ...
Get Version Control with Git 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.