vector8188
vector8188

Reputation: 1393

git diff among two different repositories in two different folder

I would like to know how can I get the git diff from 9.3.1-STABLE and TN-9.3.1-STABLE, with following folder/git structure

root@build3:/tank/home/stable-builds/FN # git branch
  9.3-STABLE
* 9.3.1-STABLE

root@build3:/tank/home/stable-builds/TN # git branch
TN-9.3-STABLE
* TN-9.3.1-STABLE
master

Any answer will be much appreciated.

Upvotes: 6

Views: 10522

Answers (3)

vector8188
vector8188

Reputation: 1393

git diff origin/9.3.1-STABLE TN-9.3.1-STABLE

this did the trick for me, actually origin/9.3.1-STABLE and TN-9.3.1-STABLE are branches in the same repo.

when I posted this question I was thinking that are 9.3.1-STABLE and TN-9.3.1-STABLE were different repo's, so sorry about the confusion if any.

# git diff --stat origin/9.3.1-STABLE TN-9.3.1-STABLE
 ChangeLog                                                |  26 +++++-
 Makefile                                                 |  12 +--
 README.md                                                |   6 +-
 ReleaseNotes                                             |  97 ++++------------------
 build/README                                             |   6 +-
 build/create_redmine_changelog.py                        |   4 +-
 build/files/install.sh                                   |   4 +-
 build/nanobsd-cfg/FREENAS.amd64                          |   3 -
 build/nanobsd-cfg/Files/etc/rc.conf.local                |   7 +-

^^^ will give you only changed files, with full path, you can do something like below to have a clear idea of what exactly changed and where.

# git diff origin/9.3.1-STABLE:ChangeLog TN-9.3.1-STABLE:ChangeLog
diff --git a/origin/9.3.1-STABLE:ChangeLog b/TN-9.3.1-STABLE:ChangeLog
index 35e315e..656c681 100644
--- a/origin/9.3.1-STABLE:ChangeLog
+++ b/TN-9.3.1-STABLE:ChangeLog
@@ -1,2 +1,24 @@
-#11936 Bug     Critical        UI left pane does not populate
-#12208 Bug     Critical        Fix late-breaking issue with ntpd update
+o Add a vCenter plugin.  This functionality allows you to install
+  the TrueNAS 1.0 vCenter plugin in to vCenter, which will then
+  allow you to create iSCSI and NFS datastores directly from vCenter.

Upvotes: 0

sergej
sergej

Reputation: 17999

If you plan to make such diffs regularly, I suggest using a remote repository as described in @BartBog's answer.

If not, you can do the following without adding a remote repository:

option 1:

git diff --no-index -- /tank/home/stable-builds/FN /tank/home/stable-builds/TN

or simply:

git diff /tank/home/stable-builds/FN /tank/home/stable-builds/TN

From the git manual:

git diff [options] [--no-index] [--] <path> <path>

This form is to compare the given two paths on the filesystem. You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.

Note: It compares the working copies on the filesystem.

option 2:

If you want to compare the FN working copy against the TN-9.3.1-STABLE branch in TN, you can do the following:

  • If you are in /tank/home/stable-builds/FN:

      git --git-dir=../TN/.git diff TN-9.3.1-STABLE
    
  • If you are somewhere else:

      git --git-dir=/tank/home/stable-builds/TN/.git --work-tree=/tank/home/stable-builds/FN diff TN-9.3.1-STABLE
    

From the git manual:

--git-dir=<path> Set the path to the repository.

--work-tree=<path> Set the path to the working tree.

Upvotes: 6

BartBog
BartBog

Reputation: 1979

First we make the two git repos know each other

Go to one repository

cd /tank/home/stable-builds/FN

Add the other repo as "remote"

git remote add TN /tank/home/stable-builds/TN

Fetch the other repo

git fetch TN

Now, we ask for a diff

git diff 9.3.1-STABLE remotes/TN/TN-9.3.1-STABLE

Upvotes: 6

Related Questions