【问题标题】:How to switch github account and retrospectively update commit history?如何切换 github 账号并追溯更新提交历史?
【发布时间】:2020-06-02 01:13:38
【问题描述】:

我使用 GitHub 帐户在私有存储库上进行了多次提交。但是,我想切换我的 github 帐户并将提交历史记录转移到新帐户,就好像我一直在使用新帐户一样。有没有办法在 GitHub 中实现这一点? 我读到了transferring repository,但我的存储库不归我所有,也没有提供转移的选项。

【问题讨论】:

    标签: git github


    【解决方案1】:

    如果您可以克隆存储库,则需要使用 newren/git-filter-repo 将作者从旧帐户重写到新帐户。

    见“How to change commit author for multiple commits using filter branch?”和
    "git filter-repo / User and email based filtering"

    git filter-repo --mailmap my-mailmap
    

    my-mailmap:

    Correct Name <correct@email.com> <old@email.com>
    

    然后你可以在 GitHub 上创建一个新的空仓库,并将所有内容推送到它:

    git remote set-url https://github.com/<me>/newRepo>
    git push --mirror
    

    【讨论】:

      猜你喜欢
      • 2021-01-06
      • 2021-09-15
      • 2011-10-26
      • 2018-11-04
      • 1970-01-01
      • 2014-07-07
      • 1970-01-01
      • 2012-07-31
      • 1970-01-01
      相关资源
      最近更新 更多