Exclude Files Tracked by Git LFS

You can exclude files tracked by Git LFS from any hook condition by using the following:

pathsMatcher
    .excludingLfsFiles() //<1>
    .matches("glob:**.jar") //<2>

Line 2: Tell pathsMatcher to exclude files tracked by Git LFS

Line 3: See if any files in the push (not already by Git LFS) with the jar file extension are present

This is particularly useful if you want a condition to block binary files, but exclude the ones already tracked by Git LFS. You could then add an error message informing the developer that they need to move these files to Git LFS if they want to push them.

You can find further configuration options for pathsMatcher here.