1

I want to search for lines in my git repository that contain a certain word/phrase by a specific author and have been changed in a specific time/revision range.

For example, I would like to see all the lines (with their file name) containing the word "TODO", which I have added in the last week.

There is a similar question, which has only a partial solution; it doesn't handle the time/revision range. Adding a revision range or the since option to the blame command in that question's answer doesn't yield the result I'm looking for.

Community
  • 1
  • 1
Eyal Roth
  • 3,895
  • 6
  • 34
  • 45

1 Answers1

2

You could do this:

$ git log -p -S TODO --author="John Doe" --since="1 week ago" |grep TODO

This will show all the commits of the last week, authored by John Doe and which contain the word TODO in the diff.

Agis
  • 32,639
  • 3
  • 73
  • 81
  • 1
    It shows the entire content of these commits. That's way too much information. I'm only looking for the TODO lines written one after the other (with no other information in between). – Eyal Roth May 29 '16 at 15:09
  • That'll omit the file name :\ – Eyal Roth May 30 '16 at 12:05