简体   繁体   English

如何在github中比较/ diff特定版本的master和fork repo

[英]How to compare/diff specific version of master and fork repo in github

There are two repos on Github: Github上有两个回购:

"Repo1" is a master that has regular commits (not yet forked by me) "Repo2" is a fork of Repo1 from about 2 years ago (not yet forked by me) “Repo1”是一个定期提交的主人(我还没有分叉)“Repo2”是大约2年前Repo1的一个分支(尚未分叉)

I want to do a DIFF between the two Repos, based on the version of code in "Repo1" that was branched by "Repo2" (approx 2 yrs ago). 我想在两个Repos之间做一个DIFF,基于“Repo1”中由“Repo2”(大约2年前)分支的代码版本。 My objective is to then get the most recent code from "Repo1", and the now isolated changes from "Repo2", and merge these into a new "Repo3", effectively bringing the changes added to a fork 2 yrs ago, into my new fork of the most recent code of "Repo1". 我的目标是从“Repo1”中获取最新的代码,以及现在从“Repo2”中分离出来的变化,并将这些变化合并为一个新的“Repo3”,有效地将2年前添加到fork中的更改添加到我的新最新代码“Repo1”的分支。

One of the issues I am having is when I try to fork more than one Fork form the same root/master it doesnt seem to work, just points me back to the first fork. 我遇到的一个问题是,当我尝试将多个Fork形式分叉到相同的root / master时,它似乎无法工作,只需将我指向第一个fork即可。 I am thinking I need to clone everythign locally, and do the required work there then push back to a new clean merged repo? 我想我需要在本地克隆everythign,并在那里做必要的工作然后推回到一个新的干净的合并回购?

Any guidance much appreciated. 任何指导非常感谢。

I try to fork more than one Fork form the same root/master 我尝试将多个Fork形式分叉为同一个root / master

You don't have to fork more than one repo: fork only the repo you intent to contribute to (through PR - Pull Request). 您不必分叉多个仓库:只分叉您想要贡献的仓库(通过PR - Pull Request)。 Here, fork Repo1, then clone it locally. 在这里,fork Repo1,然后在本地克隆它。

On your local clone, type: 在本地克隆上,键入:

git remote add /url/repo2
git fetch repo2

Then you can diff between master and repo2/master . 然后你可以masterrepo2/master之间进行repo2/master

git diff repo2/master..master

See more at " Showing which files have changed between git branches " 有关详细信息,请参阅“ 显示git分支之间的文件已更改

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

The OP qtime67 adds in the comments : OP qtime67 在评论中添加:

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. 由于Repo1在Repo2分叉后已经大大增加,我希望首先看到原来的Fork(Repo2)和叉子制造时的Repo1版本之间的核心变化。

As described in " Git diff .. ? What's the difference between having .. and no dots ", that would be using three dots: 正如“ Git diff .. ?有..和没有点之间有什么区别 ”中描述的那样,那就是使用三个点:

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

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

A three dots diff will diff from the common ancestor ( git merge-base foo master ) 一个三点差异将从共同的祖先差异( git merge-base foo master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM