Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Nifty Pre-commit: Git Hooks with Your venvNew to Visual Studio Code? Get it now.
Nifty Pre-commit: Git Hooks with Your venv

Nifty Pre-commit: Git Hooks with Your venv

Nifty

| (0) | Free
Make pre-commit and other git hooks use your Python virtual environment when you commit from the Source Control view, plus run and install pre-commit.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Nifty Pre-commit

Make pre-commit and other git hooks use your Python virtual environment when you commit from the Source Control view, plus run and install pre-commit.

Maintained. No sign-in. No telemetry. Works in VS Code, Cursor, Windsurf, VSCodium and other editors that use Open VSX.

The problem

You commit from VS Code's Source Control view and the commit fails with pre-commit: command not found, No module named black, or hooks running with the wrong Python. The same commit works in a terminal where your virtual environment is activated. It's one of the most upvoted open issues in the VS Code Python repo.

The reason: VS Code's Git extension runs git commit without your virtual environment on the PATH, so your hooks can't see the tools installed in it.

The fix

Install this extension. That's it.

A commit from the Source Control view runs the hooks with the project's .venv: pre-commit finds its tools and catches a stray print()

Run pre-commit on All Files from the Source Control toolbar, with the .venv's python

The status bar shows which environment git hooks use; clicking it shows the details

  • Hooks use your virtual environment. Commits from Source Control (and from any extension that runs git) get the environment's bin / Scripts folder first on the PATH, and VIRTUAL_ENV set, just like an activated terminal.
  • The right environment, automatically. It uses the interpreter selected in Microsoft's Python extension and follows you when you switch. Without it, it looks for .venv, venv or env in the workspace. Conda environments work too, or set one with nifty.pre-commit.environment.
  • See what hooks will use in the status bar (in projects with hooks), and click for details.
  • pre-commit commands: Run pre-commit on All Files (also on the Source Control toolbar), Run on Staged Files, Install pre-commit Hooks and Update pre-commit Hook Versions.
  • Reminds you to install hooks when a project has a .pre-commit-config.yaml but they aren't installed yet.

Works for any git hook, not only pre-commit: husky scripts that call Python tools, commit-msg checks and so on.

Commands

Command What it does
Nifty Pre-commit: Show Git Hook Environment Which environment hooks use, and which hooks are installed
Nifty Pre-commit: Choose Environment for Git Hooks… Pick a virtual environment folder or python
Nifty Pre-commit: Run pre-commit on All Files pre-commit run --all-files in a terminal
Nifty Pre-commit: Run pre-commit on Staged Files pre-commit run
Nifty Pre-commit: Install pre-commit Hooks pre-commit install
Nifty Pre-commit: Update pre-commit Hook Versions pre-commit autoupdate

Settings

Setting Default What it does
nifty.pre-commit.enabled true Give git hooks your virtual environment
nifty.pre-commit.environment "" A specific environment folder or python. Empty picks it automatically
nifty.pre-commit.showInStatusBar true Show the environment in the status bar
nifty.pre-commit.suggestInstall true Offer to install hooks when they're missing

Install

  • VS Code: search for "Nifty Pre-commit" in the Extensions view, or install from the Visual Studio Marketplace.
  • Cursor, Windsurf, VSCodium, Kiro, Antigravity: install from Open VSX.

Privacy

This extension collects no telemetry and needs no account.

More Nifty tools

  • Nifty Python Envs: venv, uv, conda & pyenv: See and manage every Python environment: project venvs (uv or venv), uv-managed Pythons, conda and pyenv. Create, activate in terminals, pick for the workspace, and manage packages. (Open VSX)
  • Nifty SVN: Subversion Source Control: Subversion in the Source Control view: changes, changelists, diffs, commit, update, blame and branches, in VS Code, Cursor and more. (Open VSX)
  • Nifty Changelists: JetBrains-Style Git Changelists: Group uncommitted files into named changelists and commit each one separately, like JetBrains IDEs, and reword old commit messages without an interactive rebase. (Open VSX)
  • Nifty Git: Git Client, Graph, Rebase & Worktrees: 14-day free trial, then $39 once. A Git client in VS Code: commit graph, drag-and-drop merge and rebase, interactive rebase, undo, worktrees. No account. (Open VSX)
  • Nifty AI Review: Review AI Agent Changes: Review what an AI agent changed, hunk by hunk: checkpoints before it runs, accept or reject each change, leave comments, and send your feedback back to the agent. (Open VSX)
  • Nifty Branches: Clean Up Merged Git Branches: Safely clean up merged, squash-merged, gone and stale git branches, with a preview and one-click restore. (Open VSX)

See all 100+ Nifty extensions and web tools at https://getnifty.dev

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft