Sometimes you find a bug in your project this has been around for a while without being noticed; It can be hard-to-track down where the bug was introduced and why just by searching through logs and diffs. Git have a slick tool called that git bisect
can is used to find out which commits introduced problem in our code-it creates a Binary search where the programmer can mark each search commits good
as or bad
; by the end of the bisect, Git shows you Exactly which commit introduced the issue. In this lesson, we walk through a example of using from git bisect
start to finish.
To get Started:
git bisect start
First, we need to find out which commits cause the problem, now assume it's the lastest commit, so we need to mark it as ' Bad ':
git bisect bad
Then, we need to find out which commits works fine, then mark it as good:
// To pick one which you is sure code works fine get<commit_id>
Then git'll show you the commits which stay between the bad and good commits and would automatically checkout the next CO Mmit. Then you can does the testing and find out whether this commit was bad or not if it was bad then mark as ' bad ' or the other W Ay around.
finnally git bisect would find out the bad commit which introduce the bugs and we are still in the bisecting state, to BAC K to normal, we need to run:
git bisect Reset
[Practical Git] Diagnose which commit broke something with git bisect