Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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