Fixing Memory Leaks with Git Bisect

A SaaS team had a memory leak. Somewhere in the last 300 commits over six weeks. Too many to inspect manually. A senior engineer wrote a 10-line test script and ran: $ git bisect run ./memory_test.sh Git performed binary search automatically. Checked out the midpoint commit. Ran the script. Narrowed the range. Repeated. 40 minutes later: first bad commit found. A dependency update with a caching layer and no eviction policy. The manual version you can use right now: $ git bisect start $ git bisect bad # current commit is broken $ git bisect good v2.3.0 # this version worked Git checks out the midpoint. You test it. Then: $ git bisect good (or bad) Repeat. In 1,000 commits: found in 10 rounds. $ git bisect reset # always run this when done The only requirement: your commits need to be testable in isolation. This is why atomic commits matter. This is why "WIP" commit messages hurt you months later. Every messy commit today is a future investigation hour. 📚 Chapter 7 of Stop Breaking Git. #Git #Debugging #SoftwareEngineering #DevOps #BestPractices

To view or add a comment, sign in

Explore content categories