I had a bug that crept up on me that wasn’t found until right before a production push. I rolled back the last two commits locally but saw that the issue was still there on the iPhone. Now I’ve heard about the wonders of git bisect but hadn’t had the opportunity to use it – until now and was pleasantly satisfied at how well it did it’s job.

Locating the problem commit:

To quickly locate the exact commit that the issue was introduced I picked an arbitrary date of 15 days ago and saw that the bug didn’t exist at that time. I ran git bisect specifying master as bad and the the commit of 15 days ago as good. git bisect then picks random commits between those two commit ranges until I find the first bad commit. The process involves me calling git bisect bad or git bisect good as I refreshed the iPhone screen. The bug was found in less than five minutes (having called git bisect six times). Fixing the bug however, took a little longer…

For a greater look into git bisect peep this link.

Bonus round

Once you find the problem commit, you can show the details of the comment by doing:

git show 97d7c26dba17ba1a46fb9c6f0bf0e954a92aec74

Cat a specific file by doing:

git show 59010bee586296f0676a9e2255b2bade6b8cea74:public/js/jellycar3/tap.js

What to grab the previous commit before that file and copy it to your local branch? Just do (while in whichever branch):

git show 59010bee586296f0676a9e2255b2bade6b8cea74^:path/to/file/tap.js > tap.js