Git bisect command

The git bisect command is used to discover the commit that has introduced a bug in the code. It helps track down the commit where the code works and the commit where it does not, hence, tracking down the commit that introduced the bug into the code.

git bisect helps to find the faulty commit by performing a binary search on the commits to reduce the time taken to find the faulty commit.

Your image is not available

Basic bisect commands
Let us look at the various commands associated with the bisect command.
• git bisect start: This command is used to make the Git work in the bisect mode apart from this, it also lets the Git wait for the further bisect commands.
• git bisect bad (commit hash or tag): This command is used to inform the commit that is bad. It can provide the hash or tag that we want.

Bash

git bisect bad

If we do not specify the commit hash then by default the current commit is marked as bad commit.
• git bisect good (commit hash or tag): This command is used to inform the commit that is good. It can also provide the hash or tag that we want.

Bash

git bisect good v2.0

Here, v2.0 is the tag name.
• git bisect reset: As the name suggests, this command is used to exit the bisect mode. Hence, when we execute this command, the Git is returned to its original mode exiting the bisect mode.