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?
- A. git log --grep='legacyPay('
- B. git blame --all
- C. git log -S 'legacyPay('
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- What does this Prototype-style code print? python import copy class Doc: def init(self, title, tags): self.title = title self.tags = tags…
- What does this Decorator-pattern code print? python class Coffee: def cost(self): return 50 def desc(self): return "coffee" class AddOn…
- What does this Chain of Responsibility code print? python class Handler: def init(self, limit, name, nxt=None): self.limit, self.name…
- What does this Singleton implemented with a metaclass print? python class Meta(type): inst = {} def call(cls, a, k): if cls not in…
- This Observer code registers three listeners. What does it print? python class Subject: def init(self): self.obs = [] def attach(self, f)…
- A drawing app has 4 shape types and must render each through 3 back-ends (SVG, Canvas, PDF). Building one subclass per combination needs…