tags:

views:

51

answers:

1

So i remember that i once did something in another project and (later removed it), that could be useful now. Thanks to some other SO post i managed to search the repository for a half remembered string..

git grep halfRemeberedNameOfFunction $(git log -g --pretty=format:%h)

and Yay! got some results

2d0bcde:path/to/project/file.c: result = halfRemeberedNameOfFunction( data );
65fc672:path/to/project/file.c: result = halfRemeberedNameOfFunction( data );
24f2858:path/to/project/file.c: result = halfRemeberedNameOfFunction( data );
252e3a5:path/to/project/file.c: result = halfRemeberedNameOfFunction( data, args );
b58bc0b:path/to/project/file.c: result = _halfRemeberedNameOfFunction( data, options );
dce8d9d:path/to/project/file.c: result = halfRemeberedNameOfFunction( data, moreData );

But it's not enough of the surrounding code? How do i get the entire file at one of those revisions?

Many thanks

+6  A: 

You can pass the file part to git show:

git show 252e3a5:path/to/project/file.c
Charles Bailey