Skip to content
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

Open
jjspace opened this issue Apr 29, 2024 · 0 comments
Open

Provide documentation for using Husky with git-lfs #1431

jjspace opened this issue Apr 29, 2024 · 0 comments

Comments

@jjspace
Copy link

jjspace commented Apr 29, 2024

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 --force does 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant