cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Administration & Architecture
Explore discussions on Databricks administration, deployment strategies, and architectural best practices. Connect with administrators and architects to optimize your Databricks environment for performance, scalability, and security.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Pre-Commit hook in Databricks

Barnita
New Contributor III

Hi team,

Anyone has any idea how to use pre-commit hooks when developing via Databricks UI?

Would specifically want to use something like isort, black, ruff etc.

I have created .pre-commit-config.yaml and pyproject.toml files in my cloned repo folder, but its not getting picked up.

Also if I try to execute `!pre-commit install` command in notebook it says "An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory?"

Any help would be much appreciated!

2 REPLIES 2

-werners-
Esteemed Contributor III

AFAIK the databricks UI has no git cli support, so it cannot execute the hooks.
But at the rate things are changing, they might add it though.
If not, when you work locally + databricks connect + dab, it works fine.

nayan_wylde
Honored Contributor III

Databricks Repos (Git folders) do not support Git hooks natively.
The error you're seeing (git failed. Is it installed, and are you in a Git repository directory?) is expected because:
1. The Databricks notebook environment does not expose a full Git CLI.
2. The workspace is not a true Git working directory, even if it's linked to a remote repo.

You cannot run pre-commit install inside a notebook because it requires access to .git/hooks, which isn't available in the Databricks UI environment.