简体   繁体   中英

How to list all files in a single Git commit with a specific text change in the diff?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM