/git-lfs-hooks

Git LFS hooks for pre-commit

Primary LanguagePythonMIT LicenseMIT

GitHub tag (latest SemVer) GitHub license

git-lfs-hooks

Git LFS hooks for pre-commit

General

pre-commit documentation: https://pre-commit.com/index.html

Git Large File Storage (LFS) page: https://git-lfs.github.com

Usage

Add the following to your .pre-commit-config.yaml file:

-   repo: https://github.com/KAUTH/git-lfs-hooks
    rev: ''  # Use the SHA or tag that you want to point to
    hooks:
    -   id: post-checkout
    -   id: post-commit
    -   id: post-merge
    -   id: pre-push

Notes

  • Since running git lfs install typically installs all related hooks, we also advise using all of them in your pre-commit configuration file.

  • The version in .version corresponds to the supported Git LFS version.

Why

Git LFS installs a series of useful Git hooks supported by specific commands that are called from the corresponding hook.

Listing the command documentation of the Git LFS hooks' implementation:

If pre-commit hooks (the same type as the ones used by Git LFS) are being used in a repository and we install Git LFS afterward, the latter tool will not be able to automatically install its hooks.

With this repository, the pre-commit framework and Git LFS can both use the hooks with no issues.

For the inverse, meaning if Git LFS is already installed and we want to start using the pre-commit framework later, pre-commit is able to migrate the existing hooks (https://pre-commit.com/#running-in-migration-mode). In this scenario, this solution is not necessary.

In any case, these hooks can be used to avoid having the Git LFS hooks in migration mode and can give a holistic view of the available hooks from the .pre-commit-config.yaml file.

License

MIT License