How to skip Git commit hooks while committing

Greg Foster
Greg Foster
Graphite software engineer

In Git, commit hooks are scripts that run automatically before or after events such as commit, push, and receive, providing a way to enforce certain actions at key points in the development process. However, there are scenarios where you might want to bypass these hooks during a commit. This guide explores why and how to skip commit hooks in Git, along with practical examples.

Git hooks are located in the hooks directory inside the .git directory of your repository. Commit hooks, specifically, include pre-commit, prepare-commit-msg, commit-msg, and post-commit hooks.

  • pre-commit: Runs before you even type in a commit message. It's used to inspect the snapshot that's about to be committed.
  • commit-msg: Invoked after the commit message is provided but before the commit is completed, to inspect and modify the commit message.
  • post-commit: Executes after the commit is finalized.

Here are some reasons why developers might choose to skip commit hooks:

  1. Speed up small changes: Sometimes, especially when making trivial changes, running commit hooks can be seen as an unnecessary delay.
  2. Bulk changes: When committing a large number of files, perhaps during a bulk refactor or formatting operation, hooks might repetitively perform unnecessary checks.
  3. Testing and debugging: At times, you might need to test the behavior of your repository without the interference of hooks.
  4. Overriding faulty or outdated hooks: In some cases, hooks might be out of date or malfunctioning, and you need to bypass them temporarily until they can be updated or fixed.

To skip commit hooks during a commit, you can use the --no-verify option with git commit. This option bypasses both the pre-commit and commit-msg hooks.

Suppose you've updated a README file or made a small comment change in your code. You know it doesn't need to go through rigorous checks, and you want to commit it quickly:

Terminal
git add README.md
git commit -m "Update README with new contact info" --no-verify

Let's say you've just reformatted your entire project using a code formatter. Running code quality checks on all files would be redundant since the formatter already aligns the code to your standards:

Terminal
git add .
git commit -m "Reformat codebase using XYZ formatter" --no-verify

While skipping commit hooks can be useful, it should be done with caution:

  • Understand what you're skipping: Know what the hooks do before deciding to bypass them. If they include critical quality or security checks, consider whether it really makes sense to avoid them.
  • Communicate with your team: If you're working in a collaborative environment, make sure your team knows and agrees with the situations in which skipping hooks is acceptable.
  • Use selectively: Reserve the use of --no-verify for rare, isolated events, not as a routine habit.

For further reading 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