如何在本地比较来自不同仓库的2个分支

huangapple go评论61阅读模式
英文:

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 是我用来做这个的,它工作得非常好。

http://meldmerge.org/

英文:

Meld was what I used for this and it works fantastically.

http://meldmerge.org/

huangapple
  • 本文由 发表于 2023年6月29日 04:20:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76576488.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定