views:

161

answers:

2

I had somewhere in my Git repository a line containing word "Foo" a couple hundreds commits before.

If there is any way to find its revision number where it was the last time without buying FishEye?

+1  A: 

Worst case scenario, use git bisect and grep?

Amber
+9  A: 

That may be addressed by the pickaxe (-S) option of gitlog

 git log -SFoo -- path_containing_change

(you can even add a time range: --since=2009.1.1 --until=2010.1.1)

-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.

diffcore-pickaxe

This transformation is used to find filepairs that represent changes that touch a specified string.
When diffcore-pickaxe is in use, it checks if there are filepairs whose "original" side has the specified string and whose "result" side does not.
Such a filepair represents "the string appeared in this changeset".
It also checks for the opposite case that loses the specified string.

VonC
Note to self: the relation between `--pickaxe-all` and `-S` can be better understood with http://lists-archives.org/git/715566-git-log-why-are-full-diff-and-pickaxe-all-separate-options.html and http://article.gmane.org/gmane.comp.version-control.git/34909
VonC
Notebis: the pickaxe option was yet another command/option I learned about following Jefromi's answers: http://stackoverflow.com/questions/2700140/how-do-i-search-git-history-for-a-disappeared-line : go upvote his original answer ;) "awesomely useful", as his answers usually are. (http://stackoverflow.com/users/119963/jefromi)
VonC
@VonC: Quite a shoutout, thanks! Conversely, I always know if you've hit a question there's no need for me to answer.
Jefromi
@Jefromi: "I always know if you've hit a question there's no need for me to answer.". Well... about that. It never hurt to check ;) I am still learning here. For instance, http://stackoverflow.com/questions/2846843/find-the-git-branch-or-branches-from-commit-id/2846918#2846918 might benefit from your expertise.
VonC
@VonC: Okay, there are exceptions to every rule; I do check, but very rarely am needed!
Jefromi