-1

Is it possible to log commits of file in git, when I know certain line, and want to show commits which edited the lines above or below that line in the scale of N lines?

I want to find, which commit broke the functionality, when certain method call or piece of code should be somewhere around another method call, but it is not, and I don't know the exact name of the missing method call or piece of code.

Tuomas Toivonen
  • 21,690
  • 47
  • 129
  • 225
  • Are you looking for `git blame` ? – Lasse V. Karlsen Feb 06 '18 at 09:35
  • Maybe this question is similar to this one: [Retrieve the commit log for a specific line in a file?](https://stackoverflow.com/questions/8435343/retrieve-the-commit-log-for-a-specific-line-in-a-file) – tgogos Feb 06 '18 at 09:36
  • Possible duplicate of [Retrieve the commit log for a specific line in a file?](https://stackoverflow.com/questions/8435343/retrieve-the-commit-log-for-a-specific-line-in-a-file) – phd Feb 06 '18 at 09:46
  • Possible duplicate, what is wrong with you people? I clearly stated I'm interested lines around, using the known line as an anchor. I want to find, which commit broke the functionality, when certain method call should be *somewhere* around another method call, but it is not. – Tuomas Toivonen Feb 06 '18 at 09:59

1 Answers1

0

using git blame would seem like the way to go:
git blame -L <from_line>,<to_line> <file>
something like:
git blame -L 20,30 main.cpp

if you need to see who made a commit affecting those lines before a certain revision , you can do so by passing it to the git blame command:
git blame -L 20,30 <rev> main.cpp

for more options just run git blame --h or git blame --help for more extensive help

stakka
  • 91
  • 1
  • 4