英文:
How to Compare 2 Branches From Different Repositories Locally
问题
我想使用GitKraken比较来自两个不同存储库的2个分支,但我只能看到如何比较同一存储库中的分支。
这两个存储库都已在本地拉取。
英文:
Using GitKraken I want to compare 2 branches from 2 different repositories, however I can only see how to compare branches within the same repository.
Both of these repositories are pulled locally.
答案1
得分: 2
你可以将对象数据库添加为备用源,并通过 id 进行比较。要在不影响原始数据的情况下临时执行此操作,请在一个临时克隆中执行以下步骤:
git clone -s --bare /path/to/repo/a `mktemp -d`; cd $_
echo >> objects/info/alternates \
$(cd /path/to/repo/b; cd $(git rev-parse --git-path objects); pwd)
git diff \
$(git -C /path/to/repo/a rev-parse abranch) \
$(git -C /path/to/repo/b rev-parse anotherbranch)
或者,如果你希望在临时克隆中显示引用,可以重新映射前缀,如下所示:
git fetch /path/to/repo/a refs/heads/*:refs/heads/repoa/*
git fetch /path/to/repo/b refs/heads/*:refs/heads/repob/*
这不会复制任何内容,因为所有对象都已经可访问,然后你可以执行以下操作:
git diff repoa/main repob/feature
或其他类似操作。
英文:
You can add the object databases as alternate sources and compare the tips by id. To do it temporarily, without affecting the originals at all, do it in a scratch clone:
git clone -s --bare /path/to/repo/a `mktemp -d`; cd $_
echo >>objects/info/alternates \
$(cd /path/to/repo/b; cd $(git rev-parse --git-path objects); pwd)
git diff \
$(git -C /path/to/repo/a rev-parse abranch) \
$(git -C /path/to/repo/b rev-parse anotherbranch)
or if you want the refs appearing in your scratch clone you can remap the prefixes like
git fetch /path/to/repo/a refs/heads/*:refs/heads/repoa/*
git fetch /path/to/repo/b refs/heads/*:refs/heads/repob/*
which will copy nothing since all the objects are already accessible, and you can then
git diff repoa/main repob/feature
or whatever.
答案2
得分: 0
Meld
是我用来做这个的,它工作得非常好。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论