Search code examples
gitcachinggit-commitpre-commit-hookjscs

Is it possible to use cache for Git pre-commit hook?


I use a pre-commit hook to check code-style and other rules for my project.

gulp.task('git-preCommit', ['jscs', 'jshint', 'tslint', 'stylint']);

Often this process is long-running. I wonder, is it possible to set some cache for changed files in Git, or in jscs, jshint etc.

For example there are 150 diff files, preCommit checked 149 successfully and threw an error on 1 (path/example.ts). I fix the last one, and when I commit next time - git cache (or some tools) will know that I fixed only 1 file and check only this one, not all 150.


Solution

  • Git does not have any cache mechanism or support for content.

    So the simple answer is NO, it cant be done within git.
    You can still use any 3rd party tool which might be suitable for you.