[Practical Git] Diagnose which commit broke something with git bisect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.