From 4d95a4133449b3f685cf1b7bbb22f0dbfa113554 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 23 Jul 2026 13:35:40 +0200 Subject: [PATCH 1/3] docs: document disabling git hooks per environment --- docs/guide/commit-hooks.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/guide/commit-hooks.md b/docs/guide/commit-hooks.md index bbd9733dcb..544379b855 100644 --- a/docs/guide/commit-hooks.md +++ b/docs/guide/commit-hooks.md @@ -58,3 +58,40 @@ export default defineConfig({ ``` This is the default Vite+ approach and should replace separate `lint-staged` configuration in most projects. Because `vp staged` reads from `vite.config.ts`, your staged-file checks stay in the same place as your lint, format, test, build, and task-runner config. + +## Disabling Hooks in Specific Environments + +The installed hooks check the environment on every run, so you can disable them per machine or per process without uninstalling anything. This is useful when commits happen outside development — for example on a production server where a flat-file CMS commits content changes. + +### Environment variable + +Set `VITE_GIT_HOOKS=0` in the environment of the process that runs `git commit`, and every Vite+ hook exits immediately without running: + +```bash +VITE_GIT_HOOKS=0 git commit -m "content update" +``` + +`HUSKY=0` is honored the same way for compatibility. Setting `VITE_GIT_HOOKS=0` in an environment also keeps `vp config` from reinstalling hooks there when a lifecycle script such as `prepare` runs. + +### Init script + +Before checking the environment variable, each hook sources an init script if one exists: + +1. `$XDG_CONFIG_HOME/vite-plus/hooks-init.sh` (defaults to `~/.config/vite-plus/hooks-init.sh`) +2. `$XDG_CONFIG_HOME/husky/init.sh` as a fallback + +To disable hooks for a whole machine, create the init script and export the variable there: + +```sh [~/.config/vite-plus/hooks-init.sh] +export VITE_GIT_HOOKS=0 +``` + +Because the hook itself reads this file, it works even when the committing process does not inherit your shell environment — a daemon or web server making commits is still covered. + +### Skipping a single commit + +To bypass hooks for one commit without any environment setup, use Git's built-in flag: + +```bash +git commit --no-verify +``` From 50f887751847c56367835c61f09f8b3b25f4ad9c Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 23 Jul 2026 13:43:54 +0200 Subject: [PATCH 2/3] docs: drop no-verify section --- docs/guide/commit-hooks.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/guide/commit-hooks.md b/docs/guide/commit-hooks.md index 544379b855..19a2a2dcc8 100644 --- a/docs/guide/commit-hooks.md +++ b/docs/guide/commit-hooks.md @@ -87,11 +87,3 @@ export VITE_GIT_HOOKS=0 ``` Because the hook itself reads this file, it works even when the committing process does not inherit your shell environment — a daemon or web server making commits is still covered. - -### Skipping a single commit - -To bypass hooks for one commit without any environment setup, use Git's built-in flag: - -```bash -git commit --no-verify -``` From 1bd3807090499318319943fe02387d7a129f37d8 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Thu, 23 Jul 2026 13:46:50 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Alexander Lichter Signed-off-by: Alexander Lichter --- docs/guide/commit-hooks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guide/commit-hooks.md b/docs/guide/commit-hooks.md index 19a2a2dcc8..1f62c83614 100644 --- a/docs/guide/commit-hooks.md +++ b/docs/guide/commit-hooks.md @@ -61,7 +61,7 @@ This is the default Vite+ approach and should replace separate `lint-staged` con ## Disabling Hooks in Specific Environments -The installed hooks check the environment on every run, so you can disable them per machine or per process without uninstalling anything. This is useful when commits happen outside development — for example on a production server where a flat-file CMS commits content changes. +The installed hooks check the environment on every run, so you can disable them per machine or per process without uninstalling anything. This is useful when commits happen outside development, for example through a flat file CMS or other processes. ### Environment variable @@ -71,7 +71,7 @@ Set `VITE_GIT_HOOKS=0` in the environment of the process that runs `git commit`, VITE_GIT_HOOKS=0 git commit -m "content update" ``` -`HUSKY=0` is honored the same way for compatibility. Setting `VITE_GIT_HOOKS=0` in an environment also keeps `vp config` from reinstalling hooks there when a lifecycle script such as `prepare` runs. +`HUSKY=0` is honored the same way for ecosystem tooling compatibility. Setting `VITE_GIT_HOOKS=0` in an environment also keeps `vp config` from reinstalling hooks there when a lifecycle script such as `prepare` runs. ### Init script @@ -86,4 +86,4 @@ To disable hooks for a whole machine, create the init script and export the vari export VITE_GIT_HOOKS=0 ``` -Because the hook itself reads this file, it works even when the committing process does not inherit your shell environment — a daemon or web server making commits is still covered. +Because the hook itself reads this file, it works even when the committing process does not inherit your shell environment, for example if a daemon or web server is making commits.