【问题标题】:How to compare/diff specific version of master and fork repo in github如何在 github 中比较/比较特定版本的 master 和 fork repo
【发布时间】:2014-07-28 16:42:38
【问题描述】:

Github 上有两个 repo:

“Repo1”是一个有定期提交的大师(我还没有分叉) “Repo2”是大约 2 年前的 Repo1 的一个分叉(我还没有分叉)

我想根据“Repo2”(大约 2 年前)分支的“Repo1”中的代码版本在两个 Repos 之间做一个 DIFF。我的目标是从“Repo1”获取最新的代码,从“Repo2”获取现在孤立的更改,并将它们合并到一个新的“Repo3”中,有效地将 2 年前添加到 fork 的更改带入我的新“Repo1”的最新代码的分支。

我遇到的一个问题是,当我尝试从同一个 root/master 分叉多个 Fork 时,它似乎不起作用,只是让我回到第一个 fork。我想我需要在本地克隆所有内容,并在那里完成所需的工作,然后推回一个新的干净合并的 repo?

非常感谢任何指导。

【问题讨论】:

    标签: git github git-diff git-fork


    【解决方案1】:

    我尝试从同一个 root/master 分叉多个 Fork

    您不必分叉多个 repo:只分叉您打算贡献的 repo(通过 PR - Pull Request)。在这里,fork Repo1,然后在本地克隆它。

    在您的本地克隆上,键入:

    git remote add /url/repo2
    git fetch repo2
    

    那你可以diff between master and repo2/master

    git diff repo2/master..master
    

    在“Showing which files have changed between git branches”查看更多信息

    git diff --name-status repo2/master..master
    

    OP qtime67 加上in the comments

    自从 Repo2 分叉以来,Repo1 已经有了很大的发展,我希望首先只看到原始 Fork (Repo2) 和分叉时的 Repo1 版本之间所做的核心更改。

    如“Git diff .. ? What's the difference between having .. and no dots”中所述,这将使用三个点:

    git diff repo2/master...master
    git diff master...repo2/master
    

    三个点的差异将与共同祖先 (git merge-base foo master) 不同

    【讨论】:

    • 感谢 Von - 自从 Repo2 分叉以来,Repo1 已经有了很大的发展,我希望首先看到原始 Fork (Repo2) 和版本之间所做的核心更改Repo1 创建分叉时。在这种情况下,我如何区分每个的特定版本?
    • 感谢您的回答!这和使用..... 的差异解释。这对我帮助很大。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-18
    • 2011-03-01
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多