This repository contains a global Git hook configuration to enforce clean commit histories by stripping unwanted metadata generated by AI assistants and CLI tools (like Claude Code, GitHub Copilot, Cursor, etc.).
- Removes
Co-Authored-Bytags injected automatically by AI tools. - Strips AI Model Mentions: Automatically removes case-insensitive references to AI models like Claude, GPT, Gemini, Llama, Mistral, DeepSeek, Qwen, etc.
- Cleans Trailing Whitespace: Ensures commit messages are compact and properly formatted without excessive trailing newlines.
- Preserves Standard Git Trailers: Keeps valid Git trailers like
Reviewed-by:andTested-by:. - E2E Test Coverage: Comes with a robust test suite to verify the hook against various commit shapes and synthetic scenarios.
To apply this hook globally across all your local Git repositories:
-
Clone this repository:
git clone https://github.com/zhymabekroman/git-hooks.git ~/SOFT/git-hooks -
Make the hook executable:
chmod +x ~/SOFT/git-hooks/prepare-commit-msg -
Set the global Git
core.hooksPath:git config --global core.hooksPath ~/SOFT/git-hooks
Note: If a repository has a local
hooksPathset (e.g.,git config --local core.hooksPath .git/hooks), it will override this global setting. To remove a local override, rungit config --local --unset core.hooksPathinside that repository.
You can run the end-to-end tests to ensure the hook behaves as expected across different edge cases:
bash test_git_hook.shThe hook currently filters mentions of the following tools and models:
Claude, Opus, Sonnet, Haiku, GPT, ChatGPT, Gemini, Copilot, Anthropic, OpenAI, Llama, Mistral, DeepSeek, Qwen, Phind, Cursor, Tabnine, Cody, Grok.