在大型Git存储库中更改多位作者 [英] Change multiple authors in a large Git repo

查看:69
本文介绍了在大型Git存储库中更改多位作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的Git存储库(将近20K提交,3GB +,10个以上的作者),我正在从Subversion迁移到Github.我已经使用 nirvdrum的svn2git (而不是

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.

所以,我要做的是在提交历史记录中重写作者电子邮件,以便Github可以正确链接到那些Github用户.

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

我不想一次重写它们(如建议更改作者和提交者的姓名和电子邮件Git中的多次提交重写Git提交的作者),因为每个作者大约需要30分钟的时间(我已经以这种方式完成了一个作者),我想在回购中的所有分支上进行所有提交,而不仅仅是当前分支.

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.

推荐答案

扩展了此答案

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

这篇关于在大型Git存储库中更改多位作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆