Just run the pre-commit script through the shell:
bash .git/hooks/pre-commit
Answer from Ilayaraja on Stack Overflowpre-commit
pre-commit.com
pre-commit
To run individual hooks use pre-commit run <hook_id>. The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.
Supported hooks
here are a few hand-picked repositories which provide pre-commit integrations · these are fairly popular and are generally known to work well in most setups
Documentation
A framework for managing and maintaining multi-language pre-commit hooks. ... Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically point out issues in code such as missing semicolons, trailing whitespace, ...
Top answer 1 of 8
241
Just run the pre-commit script through the shell:
bash .git/hooks/pre-commit
2 of 8
152
There's a Python package for this available here. Per the usage documentation:
If you want to manually run all pre-commit hooks on a repository, run
pre-commit run --all-files. To run individual hooks usepre-commit run <hook_id>.
So pre-commit run --all-files is what the OP is after.
Videos
04:52
How to Run a Python Script Upon Commit Using a Pre-Commit Hook ...
29:33
Complete guide to GitHooks - Creating your own pre-commit hooks ...
05:52
Git Pre-Commit Hooks Explained: Automate Code Checks & Prevent ...
04:45
Boost Your Python Code Quality: Pre-commit Tutorial (UV & Ruff) ...
06:51
Git Pre-commit Hooks: Boost Code Quality & Consistency! 🚀 - YouTube
12:23
Pre-Commit: Enforce coding best-practices - YouTube
Git
git-scm.com › book › en › v2 › Customizing-Git-Git-Hooks
Git - Git Hooks
The pre-commit hook is run first, before you even type in a commit message. It’s used to inspect the snapshot that’s about to be committed, to see if you’ve forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.
GitHub
github.com › pre-commit › pre-commit
GitHub - pre-commit/pre-commit: A framework for managing and maintaining multi-language pre-commit hooks. · GitHub
Starred by 15.4K users
Forked by 980 users
Languages Python 97.4% | R 2.0% | Shell 0.5% | Dockerfile 0.1% | Lua 0.0% | Ruby 0.0%
GitHub
github.com › pre-commit › action
GitHub - pre-commit/action: a GitHub action to run `pre-commit` · GitHub
name: pre-commit on: pull_request: push: branches: [main] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - uses: pre-commit/action@v3.0.1
Starred by 556 users
Forked by 208 users
npm
npmjs.com › package › pre-commit
pre-commit - npm
April 28, 2026 - pre-commit will try to run your npm test command in the root of the git repository by default unless it's the default value that is set by the npm init script.
» npm install pre-commit
Published Apr 28, 2026
Version 2.0.0
Fig
fig.io › manual › pre-commit › run
pre-commit run [hook] | Fig
pre-commit run · pre-commit sample-config · pre-commit try-repo · pre-commit uninstall · pre-commit help · Run hooks · On this page · Arguments · Options ·
GitHub
github.com › pre-commit › pre-commit › issues › 3210
running single hook on a single file runs all hooks `pre-commit run --files [filename] [hook name]` · Issue #3210 · pre-commit/pre-commit
May 30, 2024 - If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files.
Author pre-commit
GitHub
github.com › pre-commit › pre-commit › issues › 1173
Run hooks on files in specific dir, rather than using `--all-files` · Issue #1173 · pre-commit/pre-commit
Now, I'm trying to run the hooks just on files in a particular directory. I think I'm not understanding the docs and I can't find an example to work from. ... I've tried the following variations: pre-commit run --files web/modules/custom pre-commit run --files web/modules/custom/* pre-commit run --files [web/modules/custom] pre-commit run --files [web/modules/custom/*] pre-commit run --files [FILES [web/modules/custom] pre-commit run --files [FILES [web/modules/custom/*]
Author pre-commit
Xnok
xnok.github.io › infra-bootstrap-tools › docs › tools › pre-commit
Pre-commit: Your First Line of Defense for Clean Code · Infra Bootstrap Tools
2 weeks ago - Run a specific hook: To execute a single hook (e.g., to test its configuration or apply its changes without committing), use: pre-commit run <hook_id> Replace <hook_id> with the actual ID from your configuration file.
Reddit
reddit.com › r/experienceddevs › what are your pre-commit hooks?
r/ExperiencedDevs on Reddit: What are your pre-commit hooks?
June 8, 2023 -
Hi folks!
I'm curious to know what pre-commit hooks you're using.
I start with linters and formatters.
Top answer 1 of 45
208
I've found precommit hooks to be pretty clunky. A precommit hook failing comes at an awkward time and interrupts my train of thought for making a commit. I've also found that managing the tools and config for them is pretty annoying, either manually or with pre-commit . Instead, I have my editor run formatters/linters/etc and add checks for them in CI. Format-on-save is just the way to go.
2 of 45
183
No pre commit hooks at all. Linting and formatting checks are in the CI, and all projects have a VSCode devcontainer with enabled auto formatting but we don’t have pre commit hooks.
Medium
medium.com › @gnetkov › automating-code-quality-control-with-pre-commit-hooks-fdbc1ec5cfea
Automating Code Quality Control with Pre-commit Hooks | by Fedor GNETKOV | Medium
January 1, 2025 - Run Automatically: Every time you run git commit, the hooks are triggered and check your code for errors before the commit is completed. If any of the hooks fail (e.g., code formatting issues or test failures), the commit is rejected. Fix and Retry: You can fix the issues identified by the hooks and retry the commit. You can find more information about installing pre-commit on the official website: https://pre-commit.com/.
Semgrep
semgrep.dev › docs › extensions › pre-commit
Run scans on pre-commit - Semgrep
The pre-commit framework. Use these instructions to run pre-commit without logging in. You can still use custom rules or rules from the Semgrep Registry.