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.
2 Answers
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 :)
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.