Reputation: 13974
Consider a very big changeset. Upon doing git show <sha1>
, you get changes related to all files. But I am interested only in changes made to .cpp
files, rest files are not useful for my analysis.
How can I filter them out of git show
result?
Any command or option.
Upvotes: 8
Views: 1495
Reputation: 13285
Apparently Git has evolved, and allows a much simpler and intuitive syntax, e.g.:
git show b5v712n *.java
That shows only and all changes to Java files in any subdirectory. Tested with version 2.45.2 on Windows Git bash, and Linux with version 2.43.0.
Upvotes: 0
Reputation: 30938
git show -- *.cpp
works. Without --
, the glob seems unable to work properly.
Upvotes: 5
Reputation: 13974
Answer given by @ElipieKay in comment section worked for me.
Prints file names having .cpp extension.
git show --name-status 29a9f891fd -- *.cpp
Display the changes done to files with .cpp extension.
git show 29a9f891fd -- *.cpp
Upvotes: 2
Reputation: 792897
You can filter the diff which git show
outputs by providing paths or patterns to match. So in your case:
git show "*.cpp"
You need to use the appropriate quoting for your shell to ensure that Git sees the wildcard (*.cpp
) and that it isn't expanded by you shell first.
Upvotes: 2