Node.js › Git & Project Management
How would you use Git bisect to find the specific commit that introduced a regression in a Node.js application's behavior?
AdvancedAnswer
git bisect performs an efficient binary search through a range of commits, at each step asking you (or an automated test script) to mark the current commit as 'good' or 'bad', narrowing down the search space by half each time until it identifies the exact commit that introduced the regression -- combined with an automated test script that can programmatically determine good/bad status (via 'git bisect run'), this can pinpoint a regression's origin across potentially hundreds of commits in just a handful of steps.
git bisect start
git bisect bad HEAD # current commit exhibits the bug
git bisect good v1.2.0 # this earlier tagged commit was known good
# Automated: runs a test script at each step to determine good/bad automatically
git bisect run npm testReal-world example A team noticing a subtle performance regression that appeared sometime in the last month uses git bisect run with an automated benchmark script, pinpointing the exact commit that introduced a slow database query change out of over 200 commits in the affected range within just eight bisection steps.