As the title says, I want to find every commit whose diff contains specific string.
At the moment, I use
git log -p 'filename'
Which shows less like interface of every diff, where I search for the string. Then I backtrace to find the actual commit msg.
Simple alternative might be to pipe git log -p into grep, but I can not find the commit id or message that way.
To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..
The git diff command displays the differences between files in two commits or between a commit and your current repository.
Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.
Simply run git log with the -L option, and it will show you the history of a function or line of code in your codebase.
git log -p -S'string'
can be used to search for commits that add or remove a string. It doesn't behave exactly the same, because it only matches commits that actually add or remove an instance of the pattern, and not (for instance) commits where it occurs in the diff context. But maybe that's good enough for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With