git-authorship-identity-cleanup
Skill4 starsChanged 20 days agoMITView on GitHub
Use when internal names leak into public git commits.
- Commits and pushes
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- charts-in-postsSkill
- choreographySkill
- clean-writingSkill
- control-planeSkill
- councilSkill
- exo-busSkill
- exo-handoffSkill
- exo-introSkill
- github-draft-review-htmlSkill
- github-issuesSkill
- github-issue-to-prSkill
- github-pr-auditSkill
- github-pr-workflowSkill
- jevgrepSkill
- operating-doctrineSkill
- sym-protocolSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Read the offending commits back through the API (/repos/O/R/commits/<sha>): it reports the identity GitHub *displays*, which can differ …
- Very specific: line 37
Read git cat-file commit <sha>, split header/message at the blank line, and rewrite only the author, committer and parent lines.
- Distinctive: line 39
Write with git hash-object -t commit -w --stdin.
- Very specific: line 89
Never commit the internal name list: read it from an env var, a <git-dir>/ file (untracked by construction), or a repository Actions …
- Distinctive: line 98
Use when commits already carry the wrong identity (an internal name, or the user's personal identity) on an unreviewed branch.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Public commit identity cleanup
Removing an internal agent/tool name (or a private mail domain) from a public repository's commit metadata: rewrite the offending commits, prove the rewrite changed nothing but identity, and install a guard so it cannot recur. Work in an isolated mirror; never in a contributor's dirty checkout.
1. Establish the live state by read-back, not by report
git clone --mirror <url> tmp.git— the mirror includesrefs/pull/*, which a normal clone hides and which is usually where the unfixable copies live.- Scan every reachable commit's author name/email, committer name/email, subject and full message for the
offending strings and any
Co-authored-by:trailer. One script, run before and after (same script, so the two numbers are comparable). - Read the offending commits back through the API (
/repos/O/R/commits/<sha>): it reports the identity GitHub displays, which can differ from the local view you expected. - Record which refs contain the offending objects (
git merge-base --is-ancestor <bad> <ref>per ref). Those refs define the blast radius: an offending commit is reachable from every branch based on it.
2. Rewrite with plumbing, not rebase
git rebase re-stamps committer dates and filter-branch is slow and blunt. When the offending set is small
(a handful of commits), rebuild exactly those objects:
- Read
git cat-file commit <sha>, split header/message at the blank line, and rewrite only theauthor,committerandparentlines. Replace the name/email but keep the<epoch> <tz>tail verbatim. - Write with
git hash-object -t commit -w --stdin. Rebuild in dependency order so each commit's new parent is already known; rebuild descendants too, even when their own identity is fine (their parent SHA moved). - Drop
gpgsigheaders (a rewritten commit cannot keep a valid signature) and say so in the receipt. - Preserve
authorandcommitterbytes on cascade commits; change only what is offending, and match how a previous repair of the same repo left its commits — consistency beats minimalism for the reviewer.
3. Prove equivalence per commit, mechanically
For every old/new pair, assert and print PASS/FAIL: tree hash equal; message bytes equal by sha256; author date+tz
and committer date+tz equal; parent remap equals the expected mapping; commit-local git diff --binary identical;
git patch-id --stable identical; header-line diff contains only author/committer/parent lines.
Then a whole-range diff (<root-before-bad>..<new tip> vs the old equivalent) must be byte-identical, and the
%H %s list of the branch must differ in exactly the rewritten SHAs — no subject drift.
4. Push with lease, read back, then re-audit all refs
git push origin <new>:refs/heads/<b> --force-with-lease=refs/heads/<b>:<old>— always the exact expected head. On protected branches the remote prints which rules were bypassed; keep that output as receipt evidence.- A bare mirror has
remote.origin.mirror=true, so a plaingit push origin <sha>:refs/heads/mainfails with "--mirror can't be combined with refspecs": usegit -c remote.origin.mirror=false push …. - Rewriting a branch head is what removes the identity from the branch view; a branch whose own commits are clean still needs rewriting when it is based on a rewritten commit, because the branch ref makes the old commits reachable again.
- Re-clone fresh and re-run the scan. Report the residual by ref class, not as one number:
refs/heads/*must be clean, and anything left must be attributed torefs/pull/*or a stored PR record.
5. Residuals: refs/pull/* and stored records are GitHub-managed
refs/pull/N/headis pinned for a closed PR (rewriting the branch does not move it);refs/pull/N/mergeis regenerated only when the head branch is next pushed; PR records keephead_sha/merge_commit_shaforever; GitHub serves unreferenced objects by SHA (git fetch --depth=1 <url> <sha>succeeds).- None of that is reachable by a repo-side action. Only a GitHub Support purge clears it. Do not attempt to write
or delete
refs/pull/*; document it and hand the decision to the user. - Rewriting a branch does remove the identity from the branch view, and it can also drop the old objects from other PRs' merge refs for free (GitHub recomputes them for the PRs whose branch moved).
6. Squash merges take the author name from the account profile
A leak that looks impossible — the branch commits are clean, yet main has an internal name — is usually
GitHub's squash attribution: the author name comes from the merging account's profile display name at merge
time (falling back to the login when it is empty), and GitHub adds Co-authored-by: <author> when the squasher
differs from the commit author. Evidence to cite: sibling squash commits from the same account whose author name
matches the current profile state. So the durable control is the profile name plus a server-side check, not local
git config.
7. The guard: positive rules in code, names out of the repository
- Ship
.githooks/{commit-msg,pre-push}(opt-in per clone viagit config core.hooksPath .githooks) plus a CI job. Hooks are skippable with--no-verify, so the CI job is the half with teeth — and it runs on the pull-request merge commit, which is the identity a squash would publish. - Never commit the internal name list: read it from an env var, a
<git-dir>/file (untracked by construction), or a repository Actions variable (verify it is not anonymously readable:GET /repos/O/R/actions/variablesshould be 401). Only generic rules belong in code (private mail domain, empty address, bad trailer shape). - The
commit-msghook seesGIT_AUTHOR_NAME/EMAILin its environment, so it catchesgit commit --author=…before the object exists. Thepre-pushhook gets<local ref> <local sha> <remote ref> <remote sha>on stdin; usegit merge-base --is-ancestorto decide between a range and a--not --remotesfallback.
Rebuild procedure — re-attributing a branch without changing content
Use when commits already carry the wrong identity (an internal name, or the user's personal identity) on an unreviewed branch. Proven end-to-end on a 10-commit branch with one merge commit.
- Map identities explicitly and refuse to guess.
{old_email: (New Name, new@email)}. Include the target identities themselves in the map so a second run is idempotent. Abort with a loud error on any author email that is not in the map — a silent default is how a personal identity survives a "cleanup". - Rebuild with
git commit-tree, neverfilter-branch.filter-branchlinearizes merge commits and can drop a side branch from the log. For each commit ingit rev-list --topo-order --reverse <base>..<branch>: read tree, parents,%B,%aD,%cD; remap each parent through the new-SHA dict (parents outside the range pass through); thenGIT_AUTHOR_NAME/EMAIL,GIT_COMMITTER_NAME/EMAIL,GIT_AUTHOR_DATE,GIT_COMMITTER_DATE+git commit-tree <tree> -p <parent>… -m <msg>.--topo-order --reverseguarantees parents are rewritten before children. For a merge, pass both parents in order (-p p1 -p p2) and it stays a merge. - Prove the content is untouched before pushing. Assert: new tip tree == old tip tree;
git diff <old> <new>empty;git diff --stat <base> <new>== the old stat line; merge commits still present (git rev-list --merges <base>..<new>non-empty). Screenshot-grade evidence, not a claim. - Sweep the messages too. An internal name in a commit subject leaks exactly as an email does. Run the
substitution over
%Bin the same pass, then assertgit log --format=%B <range>holds no denylisted token. - Assert the end state, not just the change.
git log --format='%ae%n%ce' <range>must contain only the allowed addresses. - Push with
--force-with-lease, and only on an unreviewed branch. Report the old and new head SHAs, the count of rewrites, and the fact that CI re-ran. An identity rewrite re-triggers every workflow on those paths.
Pitfalls
git log <sha>walks ancestors;git rev-list <sha>does not. Passing a materialized SHA list togit logsilently scans the whole history and produces spectacular false positives. Pass the range ("$@") togit log, or--no-walk, and keepgit rev-list --countfor the count.IFS=$'\001'does not split in every/bin/sh(bash 3.2 on macOS, for one). Parse fields with parameter expansion (v=${line%%"$SOH"*}; rest=${line#*"$SOH"}), which is portable and needs noset -fdance.- Match denylist tokens on token boundaries, never as substrings. A substring rule flags the owner's own domain
when an internal name is a prefix of it (
acmevsacmecorp.com). Test that false-positive case explicitly. - A finding appended inside a
whileloop fed by a pipe is lost in the subshell. Accumulate findings in a temp file and check its size after the loop; a helper must useif …; then return 0; fi, notcmd && return 0. - Amend the commit you mean to amend. A stray test commit (
--author=<bad>) left at HEAD gets picked up by the next--amend, and the amend inherits its author. Re-checkgit log --oneline origin/main..HEADbefore push. - Do not verify with the mirror you rewrote in. A push from a mirror updates the mirror's own
refs/heads/main, so the "before" state is gone — takegit bundle create --allfirst and compare against that. - An identity rewrite re-triggers path-filtered workflows (Pages deploys, package releases) because the re-pushed commits carry the same paths. Prove no content changed (tree hash of the filtered directory old vs new) and say plainly that the deploy ran.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

