Search code examples
gitsvnsvn2git

Change multiple authors in a large Git repo


I have a very large Git repo (almost 20K commits, 3GB+, 10+ authors) that I am moving from Subversion into Github. I already moved the repo using nirvdrum's svn2git (not the svn2git on gitorious) however I did not have an authors file set up to map the authors. No one is using this repo yet, and no one has cloned it yet and I've told everyone that I'm making changes that will break any clone.

So, What I want to do is rewrite the author emails in the commit history so Github properly links to those Github users.

I don't want to rewrite them one at a time (as is suggested by Change the author and committer name and e-mail of multiple commits in Git and Rewrite author of Git commits) because it takes about 30 minutes per author (I already did one author this way) and I want to do all commits on all branches in the repo, not just the current branch.


Solution

  • Expanded this answer to Rewrite author of Git commits to include multiple authors and all revisions in the repo.

    git filter-branch --env-filter '
      if [ $GIT_AUTHOR_EMAIL = [email protected] ];
        then [email protected];
      fi;
      if [ $GIT_AUTHOR_EMAIL = [email protected] ];
        then [email protected];
      fi;
      if [ $GIT_AUTHOR_EMAIL = [email protected] ];
        then [email protected];
      fi;
      export GIT_AUTHOR_EMAIL' -- --all