Simon
Simon

Reputation: 4192

How Can I Find Out When A Specific Line Has Been Added/Modified With Git?

I would like to know when a specific line in a specific file has been added/modified. Hence, I know the content of the line and would like to have the commit in which this line has been added/modified.

Upvotes: 0

Views: 155

Answers (2)

Paulo Bu
Paulo Bu

Reputation: 29804

You can use git blame:

git blame path/to/file -L17,18

Will show the history for line range 17-18.

Upvotes: 3

Simon
Simon

Reputation: 4192

Based on this answer, which basically answers the same regarding the deletion of some lines, the answer is rather simple:

git log -S 'content of the line in which you are interested' <file>

Upvotes: -1

Related Questions