0

I am running this command:

diff --recursive a.git b.git

It shows differences for some files that do not concern me. Is there a way to for example not have it show lines that end in:

 ".xaml.g.cs"

or lines that start in:

 "Binary files"

or lines that have this text in them:

".git/objects"
Alan2
  • 23,493
  • 79
  • 256
  • 450

2 Answers2

3

A simple but effective way is to pipe output to grep. With grep -Ev you can ignore lines using regular expressions.

diff --recursive a.git b.git | grep -Ev "^< .xaml.g.cs|^> .xaml.g.cs"  | grep -Ev "Binary files$" | grep -v ".git/objects"

This ignores all lines with matching text. As for the regular expressions: ^ means line starts with, $ means line ends with. But at least for ^ you have to adjust it to the diff output (where lines normally start with < or >).

Also note that diff provides a flag --ignore-matching-lines=RE but it might not work as you would expect as mentioned in this question/answer. And because it does not work as I would expect I rather use grep for filtering.

Würgspaß
  • 4,660
  • 2
  • 25
  • 41
2
man diff

gives following examples:

   ...
   -x, --exclude=PAT
          exclude files that match PAT

   -X, --exclude-from=FILE
          exclude files that match any pattern in FILE
   ...

Did you try using those switches (like diff -x=".xaml.g.cs" --recursive a.git b.git)?

Dominique
  • 16,450
  • 15
  • 56
  • 112