Change multiple authors in a large Git repo

自作多情 提交于 2019-12-13 18:35:56

问题


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.


回答1:


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 = old_email1@whatever.com ];
    then GIT_AUTHOR_EMAIL=new_email1@whatever.com;
  fi;
  if [ $GIT_AUTHOR_EMAIL = old_email2@whatever.com ];
    then GIT_AUTHOR_EMAIL=new_email2@whatever.com;
  fi;
  if [ $GIT_AUTHOR_EMAIL = old_email3@whatever.com ];
    then GIT_AUTHOR_EMAIL=new_email3@whatever.com;
  fi;
  export GIT_AUTHOR_EMAIL' -- --all


来源:https://stackoverflow.com/questions/24370651/change-multiple-authors-in-a-large-git-repo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!