0

I was given a Git repository with many commits.

I was asked to find the first commit in which a certain file contained a certain string with Git Bisect and I couldn't figure out how to do it.

Thanks!

  • 1
    Did you read any materials on how to use `git bisect`? For example, https://git-scm.com/docs/git-bisect? – mkrieger1 Dec 19 '21 at 10:12
  • Yeah I've at both of those links, but couldn't understand actually how to do it – Ori Silberman Dec 19 '21 at 10:13
  • 1
    What was the problem when you tried it? What did you not understand? – mkrieger1 Dec 19 '21 at 10:14
  • I haven't tried it, because I didn't know how to approach it. – Ori Silberman Dec 19 '21 at 10:16
  • 1
    Git bisect is a little funky to wrap your brain around the first time you try to use it. Think of it as human-in-the-loop binary search. You'll be the one (in the default mode) telling bisect whether the commit it chose to look at next is "good" (i.e., it contains your string) or "bad" (it does not contain your string). Read through the answers in the duplicate and give yourself time to think about what they mean. Because binary search takes log(n) steps, you know it won't take more than a handful of checks, even for a very long history. – joanis Dec 19 '21 at 14:10

0 Answers0