I've got two different exports of our CVS repository into git. They diverge at some point, and I'm doing some investigation into why. The development line goes back several years and over tens of thousands of commits.
我有两个不同的CVS存储库导出到git中。他们在某些时候分歧,我正在调查原因。该开发线可以追溯到几年,并且有数万次提交。
At the beginning of the development line, the SHA1 IDs for each commit are identical, telling me that git-cvsimport is very consistent about what it is doing when it reads the results of cvsps and imports.
在开发行的开头,每个提交的SHA1 ID都是相同的,告诉我git-cvsimport在读取cvsps和import的结果时非常一致。
But sometime between the first commit and yesterday, the SHA1 IDs begin to diverge. I'd like to find out where this is by comparing a list of commit IDs from each repository and looking to see what's missing. Are there any good tools or techniques for doing this?
但是在第一次提交和昨天之间的某个时间,SHA1 ID开始出现分歧。我想通过比较每个存储库中的提交ID列表并查看缺少的内容来找出它的位置。这样做有什么好的工具或技术吗?
6 个解决方案
#1
Why not just cat each repo's git log to its own file and compare? The difference closest to the bottom of the file is where they started diverging...
为什么不把每个repo的git log记录到自己的文件中并进行比较?最接近文件底部的差异是它们开始发散的地方......
#2
Since the two git repositories start out the same, you can pull both into the same working repository.
由于两个git存储库的开头相同,因此您可以将两者都放到同一个工作存储库中。
$ git remote add cvsimport-a git://.../cvsimport-a.git
$ git remote add cvsimport-b git://.../cvsimport-b.git
$ git remote update
$ git log cvsimport-a/master..cvsimport-b/master # in B, not in A?
$ git log cvsimport-b/master..cvsimport-a/master # in A, not in B?
#3
In one of your repos, do the following:
在您的一个回购中,执行以下操作:
$ git remote add other-repo git://.../other-repo.git
$ git remote update
$ git log other-repo/master...master
# or maybe:
$ gitk master... other-repo/master
This gives you the symmetric difference between two repos; this shows you all of the commits that are in one repo, but not the other.
这给你两个回购之间的对称差异;这将显示一个仓库中的所有提交,但不显示另一个仓库中的提交。
#4
The obvious way would be to clone one repository, fetch the tip of the main branch of the other repository into the clone and use git merge-base on the two tips to find the common ancestor.
显而易见的方法是克隆一个存储库,将另一个存储库的主分支的尖端读取到克隆中,并在两个提示上使用git merge-base来查找共同的祖先。
#5
You can put (fetch) both repositories into single repository, either new one, or one of existing, as in responses by ephemient, Charles Bailey and Brian Campbell. Or you can use trick from Tips and Tricks page on Git Wiki, or to be more exact "How to compare two local repositories" question there.
您可以将(获取)两个存储库放入单个存储库中,无论是新存储库还是现有存储库,如同流行的Charles Bailey和Brian Campbell的响应一样。或者您可以使用Git Wiki上的提示和技巧页面中的技巧,或更准确地说“如何比较两个本地存储库”问题。
But it might be simpler to generate list of SHA-1 of commits in topological order using "git rev-list" (or "git-log" with appropriate options), and check the first revision they differ.
但是使用“git rev-list”(或带有适当选项的“git-log”)以拓扑顺序生成提交的SHA-1列表可能更简单,并检查它们不同的第一个修订版本。
#6
I had a similar need recently. I had a cloned remote project I needed to compare with a current copied code base. The git logs were not relevant, because the commits had nothing in common, and I was not sure they branched from the same code base.
我最近有类似的需求。我有一个克隆的远程项目,我需要与当前复制的代码库进行比较。 git日志不相关,因为提交没有任何共同点,我不确定它们是否从相同的代码库中分支出来。
To solve the problem, I used git in a brute force manner. I copied the files to be checked into the git repo, then checked the git status
for a list changed files.
为了解决这个问题,我以蛮力的方式使用git。我将要检查的文件复制到git仓库中,然后检查git状态以查找列表更改的文件。
Additionally, git diff <filename>
can also be used to inspect further. I was able to compare files within
另外,git diff
#1
Why not just cat each repo's git log to its own file and compare? The difference closest to the bottom of the file is where they started diverging...
为什么不把每个repo的git log记录到自己的文件中并进行比较?最接近文件底部的差异是它们开始发散的地方......
#2
Since the two git repositories start out the same, you can pull both into the same working repository.
由于两个git存储库的开头相同,因此您可以将两者都放到同一个工作存储库中。
$ git remote add cvsimport-a git://.../cvsimport-a.git
$ git remote add cvsimport-b git://.../cvsimport-b.git
$ git remote update
$ git log cvsimport-a/master..cvsimport-b/master # in B, not in A?
$ git log cvsimport-b/master..cvsimport-a/master # in A, not in B?
#3
In one of your repos, do the following:
在您的一个回购中,执行以下操作:
$ git remote add other-repo git://.../other-repo.git
$ git remote update
$ git log other-repo/master...master
# or maybe:
$ gitk master... other-repo/master
This gives you the symmetric difference between two repos; this shows you all of the commits that are in one repo, but not the other.
这给你两个回购之间的对称差异;这将显示一个仓库中的所有提交,但不显示另一个仓库中的提交。
#4
The obvious way would be to clone one repository, fetch the tip of the main branch of the other repository into the clone and use git merge-base on the two tips to find the common ancestor.
显而易见的方法是克隆一个存储库,将另一个存储库的主分支的尖端读取到克隆中,并在两个提示上使用git merge-base来查找共同的祖先。
#5
You can put (fetch) both repositories into single repository, either new one, or one of existing, as in responses by ephemient, Charles Bailey and Brian Campbell. Or you can use trick from Tips and Tricks page on Git Wiki, or to be more exact "How to compare two local repositories" question there.
您可以将(获取)两个存储库放入单个存储库中,无论是新存储库还是现有存储库,如同流行的Charles Bailey和Brian Campbell的响应一样。或者您可以使用Git Wiki上的提示和技巧页面中的技巧,或更准确地说“如何比较两个本地存储库”问题。
But it might be simpler to generate list of SHA-1 of commits in topological order using "git rev-list" (or "git-log" with appropriate options), and check the first revision they differ.
但是使用“git rev-list”(或带有适当选项的“git-log”)以拓扑顺序生成提交的SHA-1列表可能更简单,并检查它们不同的第一个修订版本。
#6
I had a similar need recently. I had a cloned remote project I needed to compare with a current copied code base. The git logs were not relevant, because the commits had nothing in common, and I was not sure they branched from the same code base.
我最近有类似的需求。我有一个克隆的远程项目,我需要与当前复制的代码库进行比较。 git日志不相关,因为提交没有任何共同点,我不确定它们是否从相同的代码库中分支出来。
To solve the problem, I used git in a brute force manner. I copied the files to be checked into the git repo, then checked the git status
for a list changed files.
为了解决这个问题,我以蛮力的方式使用git。我将要检查的文件复制到git仓库中,然后检查git状态以查找列表更改的文件。
Additionally, git diff <filename>
can also be used to inspect further. I was able to compare files within
另外,git diff