3

I found in another answer that I can list the files changed in a commit with:

git diff-tree --no-commit-id --name-only -r bd61ad98

How can I then to show only the files which include a specific text change in the diff?

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
richk
  • 1,719
  • 3
  • 12
  • 12
  • As an aside, you could also use `git diff` (which is probably what I would think to do first, since I try to keep my commonly-used command set minimal). You then *wouldn't* need the `-r` or `--no-commit-id` flags, but you would have to specify to diff against the parent (`bd61ad98^` ) – Mark Adelsberger Jun 02 '17 at 13:16

1 Answers1

3

You can use the -G flag:

-G<regex>

Look for differences whose patch text contains added/removed lines that match .

To illustrate the difference between -S<regex> --pickaxe-regex and -G<regex>, consider a commit with the following diff in the same file:

+    return !regexec(regexp, two->ptr, 1, &regmatch, 0);
...
-    hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);

While git log -G"regexec\(regexp" will show this commit, git log -S"regexec\(regexp" --pickaxe-regex will not (because the number of occurrences of that string did not change).

See the pickaxe entry in gitdiffcore[7] for more information.

For example:

git diff-tree --no-commit-id -G<regex with what you are looking at> --name-only -r bd61ad98
Community
  • 1
  • 1
developer_hatch
  • 15,898
  • 3
  • 42
  • 75