You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Hook already exists: pre-push
#!/usr/bin/env sh
. "${0%/*}/h"
To resolve this, either:
1: run `git lfs update --manual` for instructions on how to merge hooks.
2: run `git lfs update --force` to overwrite your hook.
I understand this is because the .husky/_/pre-push file is auto generated. Running git lfs install --force or git lfs update --forcedoes work to overwrite it temporarily. However, the next time the prepare script or npx 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 use config 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 and post-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 running npx husky init and git 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:
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: