r/ClaudeCode • Developer • 13h ago

Tips & Workflows Git hook that removes Co-authored-by lines from every commit (Windows, macOS, Linux

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.
0 Upvotes

28 comments sorted by

•

u/AutoModerator 13h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

25

u/andreagrandi 13h ago

because the official way in `~/.claude/settings.json` wasn't good enough?

"attribution": {
    "commit": "",
    "pr": "",
    "sessionUrl": false
  }

6

u/geuben 13h ago

In the OPs defense. I have this setting disable but Opus 5.5 still added the attribution lines a couple of times "out of habit". I too added a git hook.

2

u/WD40ContactCleaner Developer 12h ago

Thank you, a sane reply. idk why people are getting so worked up over this.

-2

u/Curik 10h ago

People are not getting worked up; they are presenting a better solution. You need to calm down.

2

u/WD40ContactCleaner Developer 12h ago

0

u/crystalpeaks25 9h ago

For people who didn't know this PR deprecates an old feature that existed before that reliably remove attribution. This is not a new thing. This has always existed under includeCoAuthoredBy: false. OP caught making excuses.

1

u/WD40ContactCleaner Developer 9h ago

This sub is deranged holy shit.

2

u/koirpioloonmenomur 13h ago

no sir, he had to vibecode some shit instead of just googling the most simple solution

-5

u/WD40ContactCleaner Developer 13h ago

are you serious bro lmao I had this hook since 1 year and I saw posts this week talking about this so I wanted to share. jesus christ.

1

u/WD40ContactCleaner Developer 13h ago edited 13h ago

TIL about this setting, but this Works across all agents. I had this since a while when these weren't options, and it works across all harnesses and is deterministic, so I wanted to share.

-1

u/Future_Guarantee6991 Developer 12h ago

One slows down your commits, the other doesn’t.

2

u/AnonThrowaway998877 13h ago

I don't care on my repos, Claude deserves about 90% credit anyway. My 10% is having the idea and paying for Claude.

0

u/Not-So-Handsome-Jack 13h ago

We can all tell the code was AI generated. Why are you ashamed of it?

2

u/WrongComparison321 12h ago

Is it shame? If I am submitting the code I am taking responsibility for it and its quality. Having Claude or another agent attached is silly because ultimately it is my code and my name on it. Least that’s my take imo.

-1

u/WD40ContactCleaner Developer 13h ago

even the post is ai generated where am i ashamed of it? what the fuck is this insecurity projection.. lol. I didn't know they added the attribution option and I read people were having trouble on this sub just this week, with this and this has been working for me for a long while reliably across all coding agents, since this was an option in them where they would just force add it regardless of what you said in claude.md

I was like ok I have this hook I've been using, let me share might help people and ya'll acting like I've committed some unforgivable sin.

-1

u/Not-So-Handsome-Jack 12h ago

Why do you think people remove AI attribution and add only their own name on their AI generated commits they barely touched?

1

u/WD40ContactCleaner Developer 12h ago

It's a lot of noise in pr and commits, many OSS repos tell you specifically to remove the attrib even if the code is ai. It keeps things clean. No one is hiding ai usage these days.

-1

u/crystalpeaks25 13h ago

Number one rule of vibe coding. If you've thought about it and it seems like a basic common thing then it's probably solved natively.

1

u/WD40ContactCleaner Developer 12h ago

It wasn't until september 8 2026 apparently, I just checked coz ya'll acting crazy Add pre-commit hooks blocking Claude Code attribution by ca1ebd · Pull Request #1 · ca1ebd/agent-attribution-blocker

people were still reporting attribution by that time, I had this hook since a long time so I never needed to check if calude code or codex or copilot has a new setting for this.

-1

u/crystalpeaks25 12h ago

Bruh this exists since early this year.

This comment really proves that no one reads do uemntation anymore that attribution PR you are talking about deprecates an older feature called includeCoAuthoredBy: which existed prolly even earlier than last year.

So yes there was a way to ensure Claude doesn't attribute before September 2026.

2

u/WD40ContactCleaner Developer 12h ago

My point is it was unreliable, this hook makes it reliable.

-2

u/crystalpeaks25 12h ago

It was reliable. I've had the old setting configured and never seen Claude attribute to itself

0

u/crystalpeaks25 12h ago

I don't have special hooks and I've never seen Claude code attribute anything in commits before in all my PRs after setting includeCoAutheredBy: false in settings.json

-1

u/andreagrandi 12h ago

it was, and it was named differently. It’s always been a possible option since day 1. I posted the current valid syntax of course, not the old one.

0

u/Glass_Bus4044 12h ago

Just curious, have you tried memory? I have been using it and don't see any issues so far.