How can I hide files in Merge Request Diffs?

I run an auto-generator which we commit to the repo.

Is there a way to hide these files in the Merge request diffs?

The issue Auto collapse diff of generated and less important code tracks such a feature request. We encourage you to vote (:+1:) to help add priority.

You can however achieve a workaround currently through the pre-existing support of .gitattributes files in the root of the repository.

  1. Create a .gitattributes file in the root of your repository
  2. Add an entry (such as the following example) in it, to mark all matching files to be treated as binaries in diff views:
# PATH/PATTERN TYPE
cxx/auto-gen/*.cpp binary
cxx/auto-gen/*.h binary
  1. Commit and push the file to the repository
  2. Try out a new MR with such files changed from your auto-generator

The workaround listed above is exactly what I want to do, but I can’t get it to work. I’ve tried putting the full path as written above and tried generic statements like “.c binary". I’ve also read somewhere that you can put ".c -diff” or “cxx/auto-gen -diff” “cxx/auto-gen/*.c -diff” to turn off a diff for all files, but no matter what I put in the Merge Request diff ignores .gitattributes file.

Any suggestions?