Skip to content

Instantly share code, notes, and snippets.

@muthuishere
Created April 5, 2026 10:42
Show Gist options
  • Select an option

  • Save muthuishere/21080f394fcdce568241c289ca97a318 to your computer and use it in GitHub Desktop.

Select an option

Save muthuishere/21080f394fcdce568241c289ca97a318 to your computer and use it in GitHub Desktop.
Global git hook: strip Co-authored-by trailers from AI agents (Copilot, Claude, Codex)
#!/bin/sh
# Global commit-msg hook: strip Co-authored-by trailers added by AI agents
COMMIT_MSG_FILE="$1"
grep -v "^Co-authored-by:.*" "$COMMIT_MSG_FILE" > "$COMMIT_MSG_FILE.tmp" && mv "$COMMIT_MSG_FILE.tmp" "$COMMIT_MSG_FILE"
exit 0

Strip Co-authored-by from AI Agent Commits (Global Git Hook)

AI agents like GitHub Copilot, Claude Code, and Codex automatically append Co-authored-by trailers to every commit. This global commit-msg hook silently removes them from all repos on your machine.

Setup

# 1. Create the global hooks directory
mkdir -p ~/.config/git/hooks

# 2. Save the hook (contents in commit-msg file in this gist)
curl -o ~/.config/git/hooks/commit-msg \
  https://gist.githubusercontent.com/muthuishere/21080f394fcdce568241c289ca97a318/raw/commit-msg

# 3. Make it executable
chmod +x ~/.config/git/hooks/commit-msg

# 4. Tell git to use it globally
git config --global core.hooksPath ~/.config/git/hooks

What it does

Strips any line matching Co-authored-by: from the commit message before the commit is recorded. Works with all git clients and AI agents.

Uninstall

git config --global --unset core.hooksPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment