Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a specific change in a specific file in Git

I have a file in a Git project that had a specific value changed at some point by someone; I don't know who or when. I want to find when the change was made, but I'm not sure how I can track that in Git.

I've tried using git diff <sha1> <sha2>, but that shows the differences for the entire project, while I want to check one particular file.

like image 355
Ahmed Avatar asked Jan 09 '13 13:01

Ahmed


2 Answers

git blame should help you. git blame <file> will show you <file>, line by line, and include on each line which user last changed that line, and in which commit.

like image 142
pjmorse Avatar answered Nov 09 '22 13:11

pjmorse


You could try:

git log --all -S oldvalue filename

This will list all commits where "oldvalue" changes (added or deleted)

like image 14
andreav Avatar answered Nov 09 '22 13:11

andreav