CS FundamentalsHardProduct-company placement · Git interview

A developer wants to find out which commit introduced the string 'legacyPay(' anywhere in the code base, even though the commit messages never mention it. Which command finds commits that added or removed that string?

  1. A. git log --grep='legacyPay('
  2. B. git blame --all
  3. C. git log -S 'legacyPay('
  4. D. git show legacyPay(

Correct answer: C. git log -S 'legacyPay('

git log -S (the pickaxe) lists commits that change the number of occurrences of the string in the code. --grep searches commit messages only; blame works on one file's current lines.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic