| name | git-author-rewrite |
| description | Rewrite all commit authors and committers in a git branch or repository history to a new name/email combination. Use this skill whenever the user mentions changing git commit authors, rewriting git attribution, mass updating committer info, fixing author names/emails across a branch history, or wants to correct commit attribution for an entire repo. Trigger even if the user doesn't explicitly mention "git-author-rewrite" or uses casual phrases like "change who wrote these commits" or "update my email on all past commits". |
git-author-rewrite
Rewrite all commit authors in a git branch to a new name/email combination. Useful for correcting attribution across an entire branch history.
Workflow
1. Get current context
git remote get-url origin
git branch --show-current
2. Clone to /tmp/ for safe rewriting
Never rewrite in-place. Always work on a clone:
git clone <repo-url> /tmp/<repo>-rewrite
cd /tmp/<repo>-rewrite
git checkout <branch>
3. Rewrite all commit authors
Use git filter-branch with --env-filter to update both author and committer:
cd /tmp/<repo>-rewrite
git filter-branch --env-filter '
GIT_AUTHOR_NAME="New Name"
GIT_AUTHOR_EMAIL="new@email.com"
GIT_COMMITTER_NAME="New Name"
GIT_COMMITTER_EMAIL="new@email.com"
' -- --all
Notes:
--all rewrites all branches and tags
- The env-filter sets both author and committer to ensure consistency
- WARNING about git-filter-branch is normal; it's acceptable for this use case
4. Verify the rewrite
Check that authors were updated correctly:
git log --format="%h %an <%ae> %s" | head -10
5. Clean up filter-branch artifacts
Remove backup refs and repack:
git for-each-ref --format='%(refname)' refs/original/ | xargs -n 1 git update-ref -d 2>/dev/null
git reflog expire --expire=now --all
git gc --prune=now
6. Apply to original repo (optional, not automatic)
If user wants to replace their local repo:
cd <original-repo>
git remote add rewritten /tmp/<repo>-rewrite
git fetch rewritten
git reset --hard rewritten/master
Important constraints
- Never push unless explicitly asked
- Always work on a clone in
/tmp/ to avoid corrupting the working directory
- Verify before applying - once rewritten, commits have new hashes
- This rewrites history - all commit SHAs will change
- Team members will need to re-clone or reset if this is pushed to shared branches
Example
User: "change the author of every commit in this branch to user name Dario clavijo email clavijodario@gmail.com"
Agent:
- Gets repo URL and branch name
- Clones to
/tmp/ImpactGuard-rewrite
- Runs filter-branch with the new author info
- Verifies with
git log
- Cleans up backup refs
- Informs user the rewritten repo is at
/tmp/ImpactGuard-rewrite and explains how to apply it