使用 github 批量更改 git 上的电子邮件地址

发布于 2024-09-16 21:48:40 字数 178 浏览 2 评论 0原文

我最近将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凉世弥音 2024-09-23 21:48:40

几乎。您需要使用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 of git filter-branch --env-filter?

︶葆Ⅱㄣ 2024-09-23 21:48:40

我还没有足够的声誉来评论 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.

你没皮卡萌 2024-09-23 21:48:40

一种方法如下:

  • 创建一个 .mbox 文件,其中包含自存储库启动以来的所有补丁: git format-patch --stdout --root > repo_history.mbox
  • 编辑 repo_history.mbox 文件,根据需要更改所有电子邮件地址。它可以像perl -pi~ -e's/oldemail\@host\.org/newemail\@newhost\.com/gi' repo_history.mbox一样简单
  • 创建一个新的存储库:mkdir 〜/ newrepo; cd ~/newrepo; git init
  • 将以前的 mbox 的更改应用到新的存储库: git am /path/to/repo_history.mbox

我刚刚在我的存储库上测试了它,上面似乎有成功了。
如果您想了解更多详细信息,请告诉我。

重要:您应该只在发布该存储库之前执行此操作,而不是在其他人已经从该存储库中提取后执行此操作 - 我看到您的问题已经说明了这一点,但是这个只是重申这一点的重要性:)

One way to do it is the following:

  • Create a .mbox file which contains all the patches since the repo's inception: git format-patch --stdout --root > repo_history.mbox
  • Edit the repo_history.mbox file, changing all e-mail addresses as you see fit. It could be as easy as perl -pi~ -e's/oldemail\@host\.org/newemail\@newhost\.com/gi' repo_history.mbox
  • Create a new repo: mkdir ~/newrepo; cd ~/newrepo; git init
  • Apply the previous mbox's changes to the new repo: 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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文