Apache Airflow Provider for Git

raw JSON →
0.3.1 verified Fri May 01 auth: no python

A provider that allows Apache Airflow to interact with Git repositories. Current version 0.3.1, supports Python >=3.10. Release cadence follows Airflow provider lifecycle.

pip install apache-airflow-providers-git
error ModuleNotFoundError: No module named 'airflow.providers.git'
cause Provider package not installed or Airflow version incompatible.
fix
Run 'pip install apache-airflow-providers-git' and ensure Airflow >=2.1.
error AirflowNotFoundException: The conn_id `git_default` isn't defined
cause Missing Airflow connection for Git.
fix
Create a Git connection in Airflow UI with Conn Id 'git_default'. Or pass a valid git_conn_id to GitHook.
deprecated The GitProvider is considered deprecated as of Airflow 2.10. No active development; consider migrating to 'gitpython' operator or custom hook.
fix Replace with airflow.providers.git.operators.git_clone or use GitPython directly via BashOperator.
gotcha GitHook requires a pre-configured Airflow connection of type 'Git'. If not set, you'll get an obscure AirflowNotFoundException.
fix Create a connection in Airflow UI with Conn Type 'Git' and provide repo URL and credentials.
breaking Renamed from 'git_hook' to 'git.hooks.git' in provider version 0.3.0. Old imports will raise ModuleNotFoundError.
fix Use 'from airflow.providers.git.hooks.git import GitHook'

Minimal example: create a Git connection in Airflow UI, then use GitHook to clone a repo.

from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.providers.git.hooks.git import GitHook
from datetime import datetime

with DAG('git_example', start_date=datetime(2024,1,1), schedule=None, catchup=False) as dag:
    def clone_repo():
        hook = GitHook(git_conn_id='my_git_conn')
        repo_dir = hook.clone_repository()
        print(f'Cloned to {repo_dir}')
    PythonOperator(task_id='clone', python_callable=clone_repo)