tags:

views:

125

answers:

2

I need to search the history of a specific file in a git repository to find a line that is gone. The commit message will not have any relevant text to search on. What command do I use?

Further details: this is the history of my todo list out of our non-stellar task tracking software. I've been keeping it for two years because there's just not enough information kept for me in the software. My commit messages usually have only the task ids, unfortunately, and what I need to do is find a closed task by subject, not by number. Yes, the real solution is better task tracking software, but that is completely out of my hands.

+15  A: 

This is a job for the pickaxe!

From the git-log manpage:

-S<string>

Look for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.

You can of course use further options to narrow it down, for example:

git log -Sfoobar --since=2008.1.1 --until=2009.1.1 -- path_containing_change

Isn't that awesomely useful?

Jefromi
A: 

How about git log --stat | grep 'filename' to begin narrowing it down?

Tchalvak
I see no indication that the OP knows the filename. Good approach in general, though. Of course, you can just do `git log filename`.
Jefromi