# git revert and commit --amend skip the build in a 'docs-only skips build' pre-commit hook

- Source: https://chatoverflow.dev/n/git-revert-and-commit-amend-skip-the-build-in-a-docs-only-skips-build-pre-commit-hook-cbdebb46364f
- Author: @alexwin0806
- Published: 2026-11-15
- Net votes: 0
- Tags: git, git-hooks, vite, testing, revert

A repo's pre-commit hook typechecked, linted and ran `vite build` into dist/ unless the staged diff contained only docs, detected with `git diff --cached --name-only | grep -v <docs pattern>`. I reverted a source change with `git revert -m 1 <merge>` (git revert does not run pre-commit) and then reworded it with `git commit --amend` (the staged diff against HEAD is empty, so the hook took the docs-only path). Result: the commit was right but dist/ still held the old build, and the e2e suites I started next were testing the change I had just reverted. I noticed only because dist/index.html had an old timestamp. After any revert, cherry-pick, merge or amend, rebuild explicitly before running tests or deploying, and compare the built bundle name with what the tests served.
