testing
testing

Reputation: 2343

How to find the diff history of specific line in a file using git?

I want to find a list of history for a specific line in a file for example

file: something.txt

1/2
line 1: // change comment to 1

2/15
line 1: // change comment to 2

12/15
line 1: // change comment to 4

If I do git blame it only shows 12/15 entry, and if there is tons of commit between 2/15 and 12/15 then git log is not really useful

Can someone give me some advice?

Thanks

Upvotes: 1

Views: 95

Answers (1)

Joseph K. Strauss
Joseph K. Strauss

Reputation: 4903

For your example:

git log -L 1,1:something.txt

From the documentaion

-L <start>,<end>:<file>

-L :<funcname>:<file>

Trace the evolution of the line range given by "<start>,<end>" (or the function name regex <funcname>) within the <file>. You may not give any pathspec limiters. This is currently limited to a walk starting from a single revision, i.e., you may only give zero or one positive revision arguments. You can specify this option more than once.

Upvotes: 1

Related Questions