Reputation: 22560
I am trying to find the difference between two branches. In my case there are a lot of .json files I am not interested in . How can I exclude the *.json files?
Upvotes: 2
Views: 1664
Reputation: 45749
You can use a pathspec to exclude the json files.
git diff -- ':!:*.jsaon'
This works with the first three forms of git diff
(as documented at https://git-scm.com/docs/git-diff). (The 4th form directly compares blob objects so doesn't care about pathspecs, and the 5th form doesn't support git's "magical" pathspecs as they aren't always easy to apply outside the current repo worktree.)
Do keep in mind that this could generate misleading results if a file is moved from a path that matches the exclusion to a path that doesn't, or vice versa. This is because the exclusion would be applied before rename detection, so as git sees it "file.json was deleted but that doesn't match my pathspec; file.wasjson was created, so I'll show that".
Upvotes: 5