-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide documentation for using Husky with git-lfs
#1431
Comments
For those looking for a (very temporary) workaround, you may want to refer to the .husky folder in one of my repositories. In short, what I've done is added a few Husky hooks ( #!/usr/bin/env bash
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs <HOOK_NAME> "$@" where This gets Git LFS working alongside Husky but, in my opinion, it's rather janky. Personal opinion? Husky should call Git LFS if it's installed and configured on the system or the user explicitly asks for it (via a CLI flag, for example) from inside it's library scripts ( |
TL;DR: please provide docs on the How To or Troubleshoot pages on the desired way to set up Git LFS alongside husky.
I have an existing repo that was set up to use husky (v9) and worked perfectly with only the
pre-commit
hook needed to lint files. I wanted to start using git lfs for some large files in the repo but going through the install process it gave the error pointed out in some other issues:I understand this is because the
.husky/_/pre-push
file is auto generated. Runninggit lfs install --force
orgit lfs update --force
does work to overwrite it temporarily. However, the next time theprepare
script ornpx husky
is run it gets set back to the one husky generates without any of the needed lfs commands. My assumption is that the change to useconfig core.hooksPath
drove a need to generate a file for every hook type even if they're not needed?After digging through old issues and PRs related to git lfs and the docs the best solution I came up with is needing to create the
pre-push
,post-checkout
,post-commit
andpost-merge
hooks that are needed by lfs myself in the.husky/
directory. This "works" but does not feel ideal, either from the perspective of installing husky or installing lfs. Both tools seem to indicate a seem less install process through runningnpx husky init
andgit lfs install
but those directly conflict with each other.Is this the only way to install git lfs in a project that uses husky?
Is there any way this could be automated by husky if it detects lfs files or config in a repo?
Or maybe could there be an extra option like
npx husky --include-lfs
that includes the lfs commands in the generated hooks?I'm not sure the best solution within the husky ecosystem but this is not the first time I've gone to use husky and run into issues with also using git lfs. I really think this should be added as a part of the husky install process or at least on the How To or Troubleshooting pages as I'd expect it's a fairly common use case.
The text was updated successfully, but these errors were encountered: