Hi folks,
Problem
I work in an open-source organization with about 11,000 commits on GitHub. Now, recently I ran into a problem i.e. I made a commit a month back and the bug I fixed was not working now. I was unable to find what is the mistake now in the code.
There were about 200 commits since then the repository, now it would be not a good idea, checking out all the commits and find which one broke the feature.
What would you do?
The purpose of this post is asking you what would have you guys done in this case to find the commit that broke the code.
Here's what I did
As GitHub doesn't allow us to get the commit using the commit number i.e. we can't find the 39th commit in a repo by just tweaking the url. But can search a commit by it's hash.
What I tried to do is binary search. Yes, seemed a nice option to me, using this not more than 7-8 commits had to be checked.
But for that I need to get the commits by the commit number. So, I built a app for that.
Github repo - https://github.com/nishantwrp/github-commit/
App - https://github-commit.netlify.com/
This app provided me a commit hash by just entering it's number.
Problem solved! I found out the culprit commit by just checking 7 other commits.
But I think it was a little overkill for this problem to build an app. What would you guys have done in such a situation?
Top comments (3)
There's actually native
git
functionality to do this: git bisectOMG! Didn't know git had this functionality. Thanks for sharing :)
You can be reassured that your instinct to do binary search was so spot-on that git already had a function for it!