How to use `git commit --no-verify`

Greg Foster
Greg Foster
Graphite software engineer

When you execute a Git commit, Git typically runs pre-commit hooks—scripts that inspect your changes before the commit is allowed. If these scripts find any issues, they can abort the commit. The --no-verify option bypasses these hooks, letting you commit changes without the checks usually performed.

This guide delves into the usage, appropriate scenarios, and provides examples of when and how to use the --no-verify option.

Pre-commit hooks can perform various checks, like syntax linting, code formatting, or running tests. While these are generally helpful, there are times when you might need to bypass them:

  • Urgency: Needing a quick fix or rollback where the hooks would cause unnecessary delay.
  • Tool issues: Encountering temporary issues with the tools or scripts configured in the hooks.
  • Partial commits: Committing work-in-progress to transfer or save state without triggering all checks.

Similar to pre-commit hooks, pre-push hooks run checks before you can push commits to a remote repository. Using --no-verify also bypasses these checks.

To commit changes without running pre-commit hooks, use:

Terminal
git commit --no-verify -m "Commit message"

This command commits the current staged changes to the repository with the provided commit message, skipping any hooks.

Here are a few practical examples demonstrating different scenarios where you might use git commit --no-verify.

Example 1: Quick hotfix commit

Suppose you need to make a quick hotfix where running extensive tests is unnecessary:

Terminal
git add hotfix_file.py
git commit --no-verify -m "fix: quick hotfix for urgent issue"

Example 2: Bypassing broken hooks

If you know that a pre-commit hook is broken or malfunctioning temporarily:

Terminal
git add .
git commit --no-verify -m "feat: add splash page fix"

Example 3: Work-in-progress commits

For work-in-progress commits that you do not want to be checked by hooks (especially when hooks are set to reject unfinished work):

Terminal
git add .
git commit --no-verify -m "WIP: adding new feature set, tests not yet passing"
  • Use sparingly: While git commit --no-verify is useful, it should be used sparingly and judiciously. Regularly skipping hooks can defeat the purpose of having quality checks in place.
  • Code quality: Ensure that the final commits, especially those merged into main development branches or deployed, undergo full checks to maintain code quality.
  • Collaboration: When working in teams, communicate the reasons for bypassing hooks, especially if the commits will affect shared branches.

For further reading on git commit hooks, and how to bypass them, see the official Git documentation on Git hooks.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2