What is git bisect ? How can you use it to ...
What is git bisect ? How can you use it to ...
Git bisect is a powerful tool for efficiently finding the commit that introduced a regression (a bug that broke previously working functionality) in your codebase. It leverages binary search to quickly pinpoint the culprit commit by repeatedly checking out commits between a known "good" state (where the bug did not exist) and a known "bad" state (where the bug does exist).
Here's how to use git bisect to find the source of a regression:
Start the bisect process by running git bisect start
.
Specify the "bad" commit where the regression exists by running git bisect bad [<bad_commit>]
. If you don't provide a commit hash, it assumes the currently checked out commit is bad.
Specify the "good" commit where the regression did not exist by running git bisect good <good_commit>
. Git will then check out a commit halfway between the good and bad commits.
Test the checked out commit to see if the regression is present. If it is, run git bisect bad
. If not, run git bisect good
.
Repeat step 4, testing each commit and marking it as good or bad, until git narrows down to the exact comm...
expert
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào