Reputation: 7540
There is a line of code that I wish to recover from a previous commit as it turns out that this line of code was very important and useful.
For example, let's say that this is my line of code:
df[df$type == "creator", ]
The problem is that I can't remember the file that this code was saved in, nor can I recall where/when it was committed.
I use SourceTree and have tried the Search
option, but it only gives me the option to search Commit Message
, File Changes
and Authors
.
I use the File Changes
search option but the results show me previous commits whereas I would like to see a list of files that contained the line of code at some point in time.
Aside from manually looking through each version of each file in each commit, I'm not sure how to approach it.
How can I do this?
Note that I am also open to suggestions/solutions using the terminal also.
Update: The line of code can be in either one of three files and I know roughly the time it was committed (about two weeks ago).
Upvotes: 0
Views: 34
Reputation: 25451
Try git log
, for example:
git log --name-only -S"<text-you-search-for-goes-here>"
It will print all commits in which any file contained the searched text at any point in time and for each commit it displays:
--name-only
)Upvotes: 2