I want to find when the last time a specific css property was removed in source on my current branch (master). I wrote:

git log -Smystring --source

It gave me a hash. I fired up gitk and pasted the hash and it gave me a huge list of files so I suspect it was just line endings. However I searched the string in gitk and can't find the string. Maybe this means it was deleted but shouldn't gitk show - ...mystring... anyways?

How do I find the line/file my string is in? I see the last few hashes using the command above but I have no idea how to pinpoint it.


Something like

git bisect start
git bisect bad AFTER
git bisect good BEFORE
git bisect run grep -v LINE FILE

where BEFORE and AFTER are commits that do and don't (respectively) contain the LINE in question. This should find the last commit between BEFORE and AFTER in which FILE contains LINE.

Once you know which commit to look in, you can use

git grep -n LINE COMMIT:FILE

to locate the LINE and its line number in the appropriate version of FILE.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.