In this article, we will see how to get the current status of git bisect.
Before we get the current status of the git bisect, first, we need to start the git bisect. Use the following command to start the git bisect.
git bisect start
The next step is to identify a good commit, that is known to be bug-free, and a bad commit, which contains the bug you are attempting to locate. To identify a good & bad commits, use the following command :
git bisect good <commit>
git bisect bad <commit>
After the above steps, git will provide us the commit to test. After testing, we should mark whether the given commit is good or bad using the following commands.
git bisect good
git bisect bad
Now, to know the status of the git bisect, use the following command to display the current status in the text format.
git bisect log
The above command shows the log of the commits that have been tested, the commits that are yet to be tested, and the commit that Git thinks is the first bad commit.
Example:
git bisect start
# good: [3d43f8ac9c232d4326d38c6f609b6a4b4c4e64a4] Add new feature
git bisect good 3d43f8ac9c232d4326d38c6f609b6a4b4c4e64a4
# bad: [d0e0aa694ca8e8d4c4ec0d79f182c0c8b34c9739] Fix critical bug
git bisect bad d0e0aa694ca8e8d4c4ec0d79f182c0c8b34c9739
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[5e1089d7d50930dc3a3e2f3d25a140bb04d01ddc] Update documentation
git bisect good
Bisecting: 1 revision left to test after this (roughly 1 step)
[27e84222f8d8a6eacdcf034d16f1d8db05e996d4] Add logging to new feature
git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[371983d53698ceab3f2b3e1f1b7dd8a74e9d7f71] Remove unused code
git bisect bad
371983d53698ceab3f2b3e1f1b7dd8a74e9d7f71 is the first bad commit
In the above example, the git bisect process started with a good commit (3d43f8ac9c232d4326d38c6f609b6a4b4c4e64a4
) and a bad commit (d0e0aa694ca8e8d4c4ec0d79f182c0c8b34c9739
). The process then tested two additional commits (5e1089d7d50930dc3a3e2f3d25a140bb04d01ddc
and 27e84222f8d8a6eacdcf034d16f1d8db05e996d4
) before identifying the first bad commit (371983d53698ceab3f2b3e1f1b7dd8a74e9d7f71
).