git - 如何在 github 中比较/区分 master 和 fork repo 的特定版本

标签 git github git-diff git-fork

Github 上有两个 repos:

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

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

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

非常感谢任何指导。

最佳答案

I try to fork more than one Fork form the same root/master

您不必 fork 多个存储库:仅 fork 您打算贡献的存储库(通过 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 :

as Repo1 has moved on greatly since Repo2 was forked, I wish to first see only the core changes made between the original Fork (Repo2) and the version of Repo1 at the time the fork was made.

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

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

http://sphinx.mythic-beasts.com/~mark/git-diff-help.png

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

关于git - 如何在 github 中比较/区分 master 和 fork repo 的特定版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24098304/

相关文章:

git - 提交怎么可能在一个分支上两次?

git - 将我所有的提交压缩为 GitHub pull 请求

git - 如何查看 Git 提交中的更改?

git - 使 git diff --stat 显示完整文件路径

c++ - 如何将外部依赖项引入跨平台 CMake 项目?

git - 如何删除特定分支的第一次提交?

git - 如何将 fork repo 的分支 merge 到原始 repo 的主分支中?

git - 找出谁是 git repo 的管理员

git - 如何恢复默认设置或使用 git diff 的 UI 工具?

git - 忽略子文件夹中的 .git 文件夹