0

I'm trying to find a commit in a legacy app. The commit removes a SOAP service from the codebase. I see a property for the url left unused. There are too many commits and I haven't managed to find any matching by its message (something like "removing..." or "get rid of...").

I would like to find in Git history files containing certain text (in my case it is usage of the property with the url). Is there a way to do it with Git?

Thank you!

UPDATE I need not deleted files names but also those deleted files containing text

Dmitry Senkovich
  • 5,521
  • 8
  • 37
  • 74
  • 1
    Possible duplicate of [How to grep (search) committed code in the git history?](https://stackoverflow.com/questions/2928584/how-to-grep-search-committed-code-in-the-git-history) – Mureinik Jun 25 '18 at 16:50

1 Answers1

2

From git log doc:

-S

Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.

It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into -S, and keep going until you get the very first version of the block.


git log -S "your-url"

If you also want the diff

git log -S "your-url" -p
Arount
  • 9,853
  • 1
  • 30
  • 43