How to search for a phrase in all git?

I need to find the word in all files of my repository and in all versions of all files. This is because I do not know when, but in one of my files there is no more code, and I want to know when it was deleted and restore it.

+4
source share
2 answers

I don't know if this was what you had in mind, but if you want to find all commits where the commit message contains the given word, use

$ git log --grep=word

If you want to find all the commits where the “word” was added or deleted in the contents of the file (more precisely: when the number of occurrences of the “word” changed), i.e. search for commit contents, use the so-called "pick" search using

$ git log -Sword

Good luck :)

+2
source

, grep ( git -grep)

$ git grep <your_search_term> $(git rev-list --all)

<your_search_term> - .

, /.

+1

Source: https://habr.com/ru/post/1605970/


All Articles