0

I would like to identify all the commits that removed a specified string from any file of the repository.

Here is the case for which I need this : I have a java method called someMethod I know this method was called in the past but it is not anymore (somebody removed the code). I don't know from which file it was called.

So this is my question : Is it possible to find which commit removed this method call. More generally, is it possible to find the commits that removed the string "someMethod" from any file? Manually, I would generate unified diff for each commit and look if someMethod appears in the diff.

Is there an automatic process to do it?

2
  • 2
    I would definitely do this the manual way: git log --all -p | less and search for "someMethod" interactively within less. Commented Jan 15, 2019 at 15:49
  • 1
    Thank you. Using this command but with grep instead of less is good for me Commented Jan 15, 2019 at 15:53

1 Answer 1

2

I would definitely do this the manual way: git log --all -p | less and search for "someMethod" interactively within less.

Using grep on the output is also a possibility, but then you have to work harder to find which commit the changes were made in.

Sign up to request clarification or add additional context in comments.

2 Comments

I also added "commit" to grep so commits are displayed too : git log --all -p | less | grep "someMethod\|commit"
Simple and effective solution, I should have thought of it. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.