Skip to main content
Bashfulrobot MFG
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Removing a Contributor from a GitHub Repository

This guide outlines the complete process for removing a contributor from a GitHub repository, including rewriting Git history to remove their commits and forcing cache updates on GitHub to reflect the changes.

Overview

Removing a contributor from a repository involves several steps:

  • History Rewriting - Remove contributor commits using git filter-repo
  • Force Push - Update the remote repository with cleaned history
  • Cache Invalidation - Force GitHub to refresh contributor data
  • Support Contact - Final escalation if automated methods fail

Prerequisites

  1. Administrative access to the target repository
  2. git-filter-repo installed (available via Nix: nix-shell -p git-filter-repo)
  3. GitHub CLI (gh) for repository management
  4. Backup of the repository before making destructive changes

Process

1. Rewrite Git History

The first step is to remove the contributor’s commits from the Git history using git filter-repo, a powerful and safe tool for rewriting repository history.

Basic Path Removal

git filter-repo --invert-paths --path-to-remove path/to/contributors/code

Commit Message Cleanup

To remove specific commit message content (such as Co-Authored-By trailers):

nix-shell -p git-filter-repo --run "git filter-repo --message-callback 'return re.sub(b"\\n\\nCo-Authored-By: Claude <noreply@anthropic.com>\\n", b"", message)' --force"

This command uses git filter-repo to rewrite commit messages and remove the specified Co-Authored-By trailer.

2. Force Push to Remote

Once the history has been rewritten, force push the changes to overwrite the existing history on the remote repository.

git push --force

3. Force GitHub Cache Update

Even after rewriting history and force-pushing changes, the old contributor may still appear on GitHub due to caching. Use the branch rename strategy to force a cache update:

Branch Rename Strategy

Renaming the default branch can trigger cache invalidation on GitHub:

  1. Rename the local branch:

    git branch -m main main-temp
    
  2. Push the renamed branch:

    git push origin main-temp
    
  3. Update GitHub’s default branch:

    gh repo edit <owner>/<repo> --default-branch main-temp
    
  4. Remove the old branch:

    git push origin --delete main
    
  5. Rename back to original:

    git branch -m main-temp main
    
  6. Push the restored branch:

    git push origin main
    
  7. Restore default branch setting:

    gh repo edit <owner>/<repo> --default-branch main
    
  8. Clean up temporary branch:

    git push origin --delete main-temp
    

Troubleshooting

Common Issues

git-filter-repo not found:

# Install via Nix
nix-shell -p git-filter-repo

# Or install globally
nix-env -iA nixpkgs.git-filter-repo

Force push rejected:

  • Verify you have admin access to the repository
  • Check if branch protection rules prevent force pushes
  • Temporarily disable branch protection if needed

GitHub CLI authentication:

# Login to GitHub CLI
gh auth login

# Verify authentication
gh auth status

Security Considerations

  • Backup First - Always create a backup before rewriting history
  • Coordinate with Team - Notify team members of history rewriting
  • Update Local Clones - Team members will need to re-clone or reset their local repositories
  • Review Changes - Verify the contributor has been completely removed

Resources