Preserves the remaining commit message content, except trailing blank lines in affected messages.
Leaves author and committer metadata, including original timestamps, unchanged.
Leaves source files unchanged.
Updates commit IDs and references to reflect the rewritten history.
The operation is performed locally. GitHub is not modified yet.
Important: This removes all co-author trailers, including any added for human collaborators. If you only want to remove AI attribution, the pattern should instead target specific AI identities or email addresses.
Step 5: Verify the result
First, confirm that no attribution trailers remain:
Next, verify that the source code and author/committer metadata are unchanged.
git-filter-repo generates a commit mapping file:
text
.git/filter-repo/commit-map
Each entry maps an original commit hash to its rewritten hash.
Run this verification script from inside repo-clean:
bash
whileread -r old new;
[[ == ]] &&
original=$(
git --git-dir=../repo-backup.git show -s \
--format=
)
rewritten=$(
git show -s \
--format=
)
[[ != ]];
1
< .git/filter-repo/commit-map
This compares every mapped commit's:
Git tree hash, representing its file contents.
Author name and email.
Original author date and timezone.
Committer name and email.
Original committer date and timezone.
If all comparisons pass, the important original metadata and snapshots are preserved. Review any errors or missing commits before proceeding.
Step 6: Push the rewritten history to GitHub
For safety, git-filter-repo normally removes your origin remote.
Restore it:
bash
git remote add origin "$REPO"
Confirm the destination:
bash
git remote -v
When satisfied with the verification, overwrite the remote branches:
bash
git push --force origin --all
Update tags:
bash
git push --force origin --tags
These commands rewrite the corresponding remote branches and tags. They require appropriate repository permissions, and GitHub branch protection rules may block force-pushing.
Avoid running git push --force --mirror indiscriminately against GitHub because it can attempt to overwrite protected GitHub-managed references.
Step 7: Verify on GitHub
Open your repository on GitHub and check:
Recent and historical commit messages no longer contain the co-author trailers.
Commit dates are displayed as expected.
Branches still reference the intended changes.
The repository contains the expected files.
GitHub's contribution and contributor displays may need time to recalculate.
Use a fresh clone for subsequent development:
bash
git clone"$REPO" repo-final
Do not push old branches from an existing checkout without reconciling them with the rewritten history, since they still reference the original commits.
Step 8: Prevent AI agents from adding attribution again
Configure your coding agents to avoid automatically inserting these trailers.
For Claude Code versions supporting the attribution setting, add the appropriate configuration to:
text
~/.claude/settings.json
For example:
json
{"attribution":{"commit":"","pr":""}}
Check your installed agent version for the supported configuration format.
Additionally, you can put this instruction in your project-level AGENTS.md or equivalent:
text
Git commit policy:
- Do not add Co-Authored-By trailers to commits.
- Do not add Generated-By or similar AI attribution.
- Preserve conventional commit formatting.
- Write concise, descriptive commit messages.
Agent instructions are a useful fallback but do not guarantee compliance. Native configuration or a Git commit-msg hook is more reliable.
Important considerations
Commit hashes are necessarily changed. A Git commit's hash depends on its content, including the message and parent commit reference. Even a one-line message change creates a different commit ID.
Dates are not reset. The history-rewriting operation above does not create new author or committer timestamps. GitHub should continue associating the rewritten commits with their original dates, although contribution counts can be recalculated.
Existing copies of the repository still contain the old history. Force-pushing does not retroactively delete objects in forks, local clones, or GitHub caches.
Signatures cannot simply survive a rewrite. Signed commits and annotated tags may need to be signed again if signature verification is important.
Conclusion
Removing unwanted AI attribution from an entire Git repository is technically straightforward with git-filter-repo.
The result is a repository in which commit messages no longer contain the unwanted Co-Authored-By lines, while the original code snapshots, authors, and timestamps remain intact.
The unavoidable trade-off is that Git commit IDs change. For independently maintained repositories without significant external dependencies on historical commit IDs, that is often an acceptable trade-off.