Git commit policy that isolates changes to specific files as separate commits

Viewed 160

I want to require SVGs to be committed separately from everything else to keep the diff output of everything else cleaner. For example, I want to disallow commits like this one:

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   src/css/main.css
        modified:   src/images/example.svg
        modified:   src/index.html

Can this be done with a pre-commit hook? How would that be written?

Edit: I think git ls-files -dmo will be useful here, but I don't know how to write the script to parse its output.

1 Answers
Related