I'm looking to step through the history of commits for a section in a file. Particularly, there are two lines I'm interested in. I want to see what changes were made to these two lines going back to a few months ago, or even the origin of the file. Is there a quick way to get the changes using the command line? I know there are GUI's for git that allow you to do this, but I'd prefer not to. I'd rather use vim or sublime if I'm going to do that.
Ideally I want something like the commit hash, date, name, and change.
34hi5u3k 4/13/2013 Someone Name (Line 408) $text = 'Something';
72wbedfj 4/05/2013 Someone Else (Line 408) $text = 'Something else';
827y3hrj 3/29/2013 Someone Nice (Line 408) $text = 'This one time...';
Show all changes to lines 95-105 in $filename:
git log -L 95,105:$filename
Show all changes to 10 lines starting at regex in $filename:
git log -L /<regex>/,+10:$filename
The output produced is not in the ideal format you mentioned, but it does show all diffs for the specified section for the entire history.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With