I need to search a word in all files of my repository and in all version of all files. This because I don't know when, but there is no more a piece of code in one of my file and I want to know when was deleted and recover it.
Asked
Active
Viewed 108 times
2 Answers
2
I don't know if this was what you meant, but if you want to find all commits where commit message contains given word, use
$ git log --grep=word
If you want to find all commits where "word" was added or removed in the file contents (to be more exact: where number of occurences of "word" changed), i.e. search the commit contents, use so called 'pickaxe' search with
$ git log -Sword
Good Luck :)

Doggy-B
- 47
- 10
-
-
I actually got this off another question on stackoverflow, all I did was search google for "how to grep git commits", or well, "how to search git commits" – Doggy-B Sep 07 '15 at 15:24
-
1
What you're looking to do here is grep (documentation on git-grep) through the history of all revisions in the repository:
$ git grep <your_search_term> $(git rev-list --all)
Where <your_search_term>
is a regex pattern.
The output will include all of the commits including your found text/expression.

Thomas Stringer
- 5,682
- 3
- 24
- 40