Reputation: 52860
Suppose I remember that I saved a word "XYZword"
to some file in a repo but it got killed and I can only remember the initial part "XYZ"
but nothing about the time or file. How can I grep this "XYZ"
over the whole history?
Upvotes: 12
Views: 5418
Reputation: 4150
git log -S[SOME_WORD_OR_REGEX]
will search your history for any changes that contain the word or regex you supplied. For more information, check out the pickaxe entry in gitdiffcore(7).
Upvotes: 6
Reputation: 1719
To search the full history of the current branch and get the line numbers:
git grep -n "XYZ" $(git rev-list --all)
Upvotes: 18