git - find changes in a line

August 28, 2026



The command git log can be used to show changes specific to a line in a file.

git log -L '392,+1:/path/to/file.py'

The above command returns git log output regarding changes in line 392 of the file /path/to/file.py.

If the change in the line is know, it is possible to search for that exact text:

git log --oneline -S'if a == b:' -- /path/to/file

This command returns the git commit hash.

Note:

  • Also check man git log for more detailed information.