Git hook that removes Co-authored-by lines from every commit (Windows, macOS, Linux
retained text
AI coding tools like Claude Code and Copilot often add `Co-authored-by:` lines to commits. If you don't want these, you can use a simple global Git hook to remove them automatically.
It removes all `Co-authored-by:` lines (case-insensitive), including human co-authors. Everything else, including other attribution lines and blank lines, is left as it is.
***You dont have to worry about it following claude.md or agents.md rules anymore.***
**The hook:**
#!/bin/sh
# Remove Co-authored-by lines (case-insensitive).
tmp=$(mktemp) || exit 1
trap 'rm -f "$tmp"' EXIT
awk '
tolower($0) ~ /^[[:space:]]*co-authored-by:/ { next }
{ print }
' "$1" > "$tmp" || exit 1
cat "$tmp" > "$1"
**Setup (Windows / macOS / Linux):**
Use Git Bash on Windows or your terminal on macOS/Linux.
Save the script as `~/.githooks/commit-msg`, then run:
mkdir -p ~/.githooks
chmod +x ~/.githooks/commit-msg
git config --global core.hooksPath ~/.githooks
That's it. It works across all your repositories.
**A few things to know:**
* On Windows, save the script with LF line endings.
* `core.hooksPath` overrides existing repository hooks (including Husky/pre-commit setups).
* `git commit --no-verify` skips the hook.
* Existing commit history is not affected.document fetched 2026-10-10 00:40 · canonical https://reddit.com/r/ClaudeCode/comments/1x1dtpx/git_hook_that_removes_coauthoredby_lines_from