'Easiest way to find when a specific change occured in git

Let's say I have a file, say foo.py. Browsing the code, some changed occured and I would need to know when that specific change was made. For instance:

def bar():
   answer = 43
   return f"The answer is:{answer}"

The answer obviously being 42, and there not having a comment, I need to find out when in the commit history that line was changed to understand if it is legit or not.

Any good, programmatic way to do this? Or is just browsing the commit history the way to do it?

git


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source