使用 github 批量更改 git 上的电子邮件地址
我最近将 hg 存储库克隆到 git,以便我可以将其发布到 github 上。很多电子邮件地址都是错误的,我想在任何人 fork 这个项目之前使用 git rebase 来更改它们。如果我更改它们,我该如何将新的、完全重新基于的存储库推送到 github?我可以先变基然后git push
吗?我必须先删除该项目吗?
I have recently cloned an hg repo to git so i can post it on github. Lots of the email addresses are wrong and I would like to use git rebase to change them before anyone forks this project. If i change them how do I go about pushing the new, completely rebased repo to github? can I just rebase and then git push
? do i have to delete the project first?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
几乎。您需要使用
git push -f
(或--force
)来覆盖旧历史记录。完全不同的说明:为什么您“喜欢使用 git rebase”来更改提交者电子邮件地址而不是 git filter-branch --env -过滤器?
Almost. You need to use
git push -f
(or--force
) in order to overwrite the old history.On a completely different note: why would you "like to use
git rebase
" to change the committer e-mail addresses instead ofgit filter-branch --env-filter
?我还没有足够的声誉来评论 Jörg 的帖子,但 github 有一个很好的 shell 脚本,使用 git filter-branch --env-filter 帮助我在 http://help.github.com/changing-author-info/。这是 Jörg 帖子中其他评论者所谈论的一个例子。这对我有用。
I don't have enough reputation just yet to comment on Jörg's post, but github has a nice shell script using
git filter-branch --env-filter
that helped me do the same thing at http://help.github.com/changing-author-info/. This is an example of what the other commenters on Jörg's post were talking about. This worked for me.一种方法如下:
repo_history.mbox
文件,根据需要更改所有电子邮件地址。它可以像perl -pi~ -e's/oldemail\@host\.org/newemail\@newhost\.com/gi' repo_history.mbox
一样简单mkdir 〜/ newrepo; cd ~/newrepo; git init
git am /path/to/repo_history.mbox
我刚刚在我的存储库上测试了它,上面似乎有成功了。
如果您想了解更多详细信息,请告诉我。
重要:您应该只在发布该存储库之前执行此操作,而不是在其他人已经从该存储库中提取后执行此操作 - 我看到您的问题已经说明了这一点,但是这个只是重申这一点的重要性:)
One way to do it is the following:
git format-patch --stdout --root > repo_history.mbox
repo_history.mbox
file, changing all e-mail addresses as you see fit. It could be as easy asperl -pi~ -e's/oldemail\@host\.org/newemail\@newhost\.com/gi' repo_history.mbox
mkdir ~/newrepo; cd ~/newrepo; git init
git am /path/to/repo_history.mbox
I just tested it on a repo of mine, and it seems like the above has done the trick.
Let me know if you'd like more details.
Important: You should only do this before you ever publish that repository, and not once other people have already pulled from it -- I see your question states that already, but this is just to reiterate the importance of this :)