This global git hook automatically removes Claude Code's Co-Authored-By: line from all commit messages across all repositories.
- Configure git to use a global hooks directory:
mkdir -p ~/.git-hooks
git config --global core.hooksPath ~/.git-hooks- Create the commit-msg hook:
touch ~/.git-hooks/commit-msg
chmod +x ~/.git-hooks/commit-msg- Add the following content to
~/.git-hooks/commit-msg:
For macOS:
#!/bin/sh
#
# Filter out Claude Code co-author attribution from commit messages
#
# Read the commit message file
COMMIT_MSG_FILE=$1
# Remove Claude-specific Co-Authored-By line
sed -i '' '/Co-Authored-By: Claude/d' "$COMMIT_MSG_FILE"
# Remove trailing blank lines (but keep the message content)
perl -i -pe 's/\n+$/\n/' "$COMMIT_MSG_FILE"For Linux:
#!/bin/sh
#
# Filter out Claude Code co-author attribution from commit messages
#
# Read the commit message file
COMMIT_MSG_FILE=$1
# Remove Claude-specific Co-Authored-By line
sed -i '/Co-Authored-By: Claude/d' "$COMMIT_MSG_FILE"
# Remove trailing blank lines (but keep the message content)
perl -i -pe 's/\n+$/\n/' "$COMMIT_MSG_FILE"The hook automatically removes Claude Code's co-author attribution from commit messages:
Co-Authored-By: Claude <[email protected]>
Note: This only filters out Claude-specific attribution. Other Co-Authored-By: lines (from human contributors) will be preserved.
Before hook:
Add new feature
This is a description.
Co-Authored-By: Claude <[email protected]>
After hook:
Add new feature
This is a description.
- This is a global git hook that applies to all repositories on your machine
- The hook runs automatically on every
git commitin any repository - It silently filters out Claude's co-author line without any error messages