【问题标题】:How do I sync a GitHub forked repository with upstream after rewrite of master?重写 master 后,如何将 GitHub 分叉存储库与上游同步?
【发布时间】:2018-12-20 10:42:53
【问题描述】:

我有一些带有我的功能分支的分叉存储库。我使用fetch/merge 使其与上游保持同步。 在某些时候,上游所有者编辑了一个提交 (C2) 并重写了从该点向前 (C2'-C3') 的整个历史记录。

----C1---C2'--...---C3'--C5---...---C6(upstream/master)
     \
      ---C2---...---C3(origin/master)
                     \
                      ---C4(origin/feature-branch)

我现在如何让我的分叉同步?我想以某种方式用 C2'-C3' 重写 C2-C3,在 C3' 之上 rebase C4,然后将我的 fork 同步到 C6。我想避免将 C6 合并到 C3 中。

已解决:

$ git fetch upstream
$ git reset --hard upstream/master --
$ git push origin +master
$ git checkout feature-branch
$ git reset --hard master --
$ git cherry-pick C4
$ git push origin +feature-branch

【问题讨论】:

标签: git github


【解决方案1】:

只要是几次提交,你总是可以使用git cherry-pick (https://git-scm.com/docs/git-cherry-pick)。

一种方法是克隆你的主分支,将主分支重置为上游/主分支,然后从克隆的分支中挑选你想要的提交。

【讨论】:

    猜你喜欢
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 2021-03-05
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多