This guide shows you how to add the ai-prepare-commit-msg hook to your repository. Choose the method that fits your workflow.
Prerequisites
- You have a Git repository.
- You can run
gitcommands from your shell. - For the
pre-commitmethod, you havepre-commitinstalled.
Install with pre-commit (recommended)
Add the repository to your .pre-commit-config.yaml:
default_install_hook_types:
- pre-commit
- prepare-commit-msg
repos:
- repo: https://github.com/electrocucaracha/ai-prepare-commit-msg
rev: e1fda3d307234dd12d0eb9161007ab6bd89fba37
hooks:
- id: ai-prepare-commit
stages:
- prepare-commit-msg
Install the Git hook:
pre-commit install --hook-type prepare-commit-msg
Install directly in .git/hooks
Copy or symlink the hook script into your local Git hooks directory:
cp <path-to-hook-script> .git/hooks/prepare-commit-msg
chmod +x .git/hooks/prepare-commit-msg
Verify installation
Run a test commit in a repository with staged changes. When your editor opens, you should see a generated commit message draft.