How to Compare 2 Branches From Different Repositories Locally

109 Views Asked by At

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.

2

There are 2 best solutions below

0
Matt On BEST ANSWER

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

http://meldmerge.org/

0
jthill On

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.