How can I find the last working commit after multiple changes?

0
16
Asked By CuriousCoder92 On

I just had an interview where I was asked a tricky version control question. The scenario was: the master branch was passing all tests when I went on vacation, but while I was away, a ton of commits were made. Now that I'm back, the tests are failing, and I need to identify the latest commit that passed the tests. The catch is, building the project takes several hours, and I can only build it once. Checking Git dif and history is not useful because of the immense number of changes. How should I tackle this?

4 Answers

Answered By DevDude84 On

I’d probably check the pipeline history to see the last successful commit that passed all tests. That could help narrow it down without needing to build everything.

CodeNinja77 -

Yeah, that was my thought too.

Answered By PragmaticProgrammer On

The real answer is to avoid merging any commits that don't pass all tests into the master branch. You need a proper setup where only tested code reaches master—it's unreasonable to assume you’ll know their structure if they let untested code through like that.

Answered By CodeWhisperer On

You might want to try `git bisect`. It’s a handy tool for finding which commit broke things, as long as you can run tests on it.

BuildBoss88 -

But how would you run the tests if you can only build once?

Answered By SkepticalDev99 On

Why do I get the feeling that if you land this job, you might end up doing this sort of thing?

VacationVibes23 -

Taking vacations? Unlikely... lol.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.