Git LFS and husky prepush hook?
See original GitHub issueI just tried to husky a prepush script and nothing happened. Looking at .git/hooks/pre-push I see that I already have a hook there:
#!/bin/sh
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 .git/hooks/pre-push.\n"; exit 2; }
git lfs pre-push "$@"
Running node node_modules/husky/bin/install.js doesn’t help:
husky
setting up hooks
skipping pre-push hook (existing user hook)
done
I guess that’s good, as I don’t want Git LFS to break and get some large files in the repo without noticing…
Is there a husky solution for having a prepush while also using git-lfs?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:36
- Comments:41 (2 by maintainers)
Top Results From Across the Web
Pair husky with Git LFS in your JavaScript project
$ git lfs install Hook already exists: pre-push … To resolve this, either: 1: run `git lfs update --manual` for instructions on how...
Read more >"Hook already exists: pre-push" after adding new git hook
In a nutshell, you need to install the LFS hooks first, move them to a separate directory and then install the Husky hooks....
Read more >Getting Started with Git Hooks and Husky | Tower Blog
In this fun tutorial, let's see how Git hooks work by creating 5 different hooks with Husky, a popular JavaScript package.
Read more >Developers - Git LFS and husky prepush hook? - - Bountysource
I just tried to husky a prepush script and nothing happened. Looking at .git/hooks/pre-push I see that I already have a hook there:...
Read more >Git Hooks | Atlassian Git Tutorial
If you take a look inside .git/hooks , you'll find the following files: applypatch-msg.sample pre-push.sample commit-msg.sample pre-rebase.sample ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To summarize suggestions by @jmchambers and @Fandekasp, the following works for me and keeps the hooks under version control as desired:
git lfs update --manualchmod +x hooks/*-lfsYes, this does mean that if those hooks for LFS ever change that your hook files would need to be updated to stay in sync, but if you look at those hooks files they are pretty inert - they just call the git lfs commands that must possess the actual business logic for the hooks. So I would estimate that is a minor issue - and would be easily solved after a future breaking change by repeating the here-entailed process of saving the hooks from
git lfs update --manualto files, easily enforced by noticing that runninggit lfs updatespits out an error after said future update, just like the first time you ran into this which brought you here…What would probably solve the issue: ability to add hooks code instead of replacing it. For example: