Every line of code written is a potential bug, we all intruduce bugs in our systems no matter how experienced or brilliant a developer you are. So it only makes sense to arm yourself with good bug hunting skills. One of my favourite is hunting down a git commit that introduced the bug. This can be easily achieved by using
# Start bisecting git bisect start # give git bisect a commit where there is no bug git bisect good b584b434 # give git bisect a commit where the known issue manifests git bisect bad a67fury7
After testing each commit either mark it as good or bad depending on whether the bug shows it self. Used
git bisect good where there is no bug, and
git bisect bad where you see issues.
The bisect algorithm is based on a binary search implementation, and it is quicker than going through each commit manually, the process can also be automated to run a script or unit tests and marks the commit as either good or bad automatically depending on the result of the script. I’ve only used the manual method shown above.