Rewriting git history is a destructive operation. Only do this if:
- The repository hasn't been widely shared yet
- You're comfortable with force-pushing
- You've backed up your repository
If the repo is already public and in use, skip this and accept the mixed authorship.
Your git history has commits from three authors:
- Matt Strautmann (167921793+matt-strautmann@users.noreply.github.com) - GitHub identity
- matt-strautmann (matt.strautmann@gmail.com) - Personal email
- Claude (noreply@anthropic.com) - AI assistant commits
This will rewrite all commits to use a single author identity.
Decide which identity you want to use:
Option A: GitHub Identity (Recommended)
git config user.name "matt-strautmann"
git config user.email "167921793+matt-strautmann@users.noreply.github.com"Option B: Personal Email
git config user.name "Matt Strautmann"
git config user.email "matt.strautmann@gmail.com"# Create a backup branch
git branch backup-before-rewrite
# Or create a complete backup
cd ..
cp -r sbdk.dev sbdk.dev-backup
cd sbdk.dev# Rewrite all commits to use current git config
git filter-branch --env-filter '
CORRECT_NAME="matt-strautmann"
CORRECT_EMAIL="167921793+matt-strautmann@users.noreply.github.com"
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
' --tag-name-filter cat -- --branches --tagsOr use git-filter-repo (faster, recommended):
# Install git-filter-repo
# macOS: brew install git-filter-repo
# Other: pip install git-filter-repo
# Create mailmap file
cat > mailmap.txt <<EOF
matt-strautmann <167921793+matt-strautmann@users.noreply.github.com> Claude <noreply@anthropic.com>
matt-strautmann <167921793+matt-strautmann@users.noreply.github.com> matt-strautmann <matt.strautmann@gmail.com>
matt-strautmann <167921793+matt-strautmann@users.noreply.github.com> Matt Strautmann <167921793+matt-strautmann@users.noreply.github.com>
EOF
# Apply mailmap
git filter-repo --mailmap mailmap.txt --force# DANGER: This will rewrite history on GitHub
git push origin main --force
# If you have other branches, push them too
git push origin --all --force
git push origin --tags --forceAnyone who has cloned the repository will need to:
cd sbdk.dev
git fetch origin
git reset --hard origin/mainIf you don't want to rewrite history, just ensure future commits use the correct identity:
# Set local repository config
git config user.name "matt-strautmann"
git config user.email "167921793+matt-strautmann@users.noreply.github.com"
# Or set global config for all repos
git config --global user.name "matt-strautmann"
git config --global user.email "167921793+matt-strautmann@users.noreply.github.com"This won't change existing commits but ensures all new commits use the correct identity.
GitHub supports .mailmap to consolidate author identities for display purposes (doesn't rewrite history):
# Create .mailmap file in repo root
cat > .mailmap <<EOF
matt-strautmann <167921793+matt-strautmann@users.noreply.github.com> Claude <noreply@anthropic.com>
matt-strautmann <167921793+matt-strautmann@users.noreply.github.com> matt-strautmann <matt.strautmann@gmail.com>
matt-strautmann <167921793+matt-strautmann@users.noreply.github.com> Matt Strautmann <167921793+matt-strautmann@users.noreply.github.com>
EOF
# Commit the mailmap
git add .mailmap
git commit -m "chore: add mailmap to consolidate author identities"
git push origin mainThis will make GitHub show all commits as from matt-strautmann in the UI, but the actual git history remains unchanged.
# Local branches
git branch -a
# Remote branches
git branch -r# Delete local branch
git branch -d branch-name
# Force delete local branch
git branch -D branch-name
# Delete remote branch
git push origin --delete branch-name# List remote branches (excluding main)
git branch -r | grep -v 'origin/main' | grep -v 'origin/HEAD'
# Delete all remote branches except main (careful!)
git branch -r | grep -v 'origin/main' | grep -v 'origin/HEAD' | sed 's/origin\///' | xargs -I {} git push origin --delete {}If you want to update recent commit messages (last few commits only):
# Interactive rebase for last 5 commits
git rebase -i HEAD~5
# In the editor, change 'pick' to 'reword' for commits you want to update
# Save and close, then edit each commit message as promptedAfter rebasing:
git push origin main --forceFor a public reference implementation repository, I recommend:
Option 3: Use .mailmap (simplest, non-destructive)
- Add .mailmap file to consolidate identities
- This only affects GitHub's display
- No history rewrite needed
- Safe for public repositories
Then commit your current changes:
git add .
git commit -m "chore: prepare repository for public archive (November 2025)
- Remove sensitive keys and tokens
- Update documentation for archived status
- Fix repository URLs
- Add GitHub setup documentation"
git push origin mainAfter cleanup, verify:
# Check recent commits
git log --pretty=format:"%an <%ae>" -10 | sort | uniq
# Check all unique authors in history
git log --all --format='%aN <%aE>' | sort | uniq
# Check contributor stats
git shortlog -sn --all- Verified all commits have desired author
- Backed up repository before rewrite
- Force pushed to GitHub (if rewrote history)
- Notified collaborators to reset their clones
- Tested repository builds successfully
- Updated .mailmap if using Option 3
- Deleted unnecessary branches
- Verified GitHub displays authors correctly