Search code examples
gitdiffgit-diff

How to create interdiff between two file with git?


We have two patch files, patch-old.patch and patch-new.patch and we want to generate an interdiff file. How can we do this?

We have tried the following using Git Bash, but it results in an empty interdiff.txt file.

git diff path/to/patch-old.patch path/to/patch-new.patch > interdiff.text

When we do the following, it doesn't show anything in Git Bash

git diff path/to/patch-old.patch path/to/patch-new.patch

Solution

  • Besides my earlier comment (which is aimed at getting you the result you want, rather than just answering your question), if your two files path/to/patch-new|old.patch are both inside a Git repository and you are inside a Git repository, you must use git diff --no-index to diff them. This is true even if the files are not tracked.

    For instance, in my Git repository for Git:

    $ git diff git-svn git-tag
    $ git diff --no-index git-svn git-tag
    diff --git a/git-svn b/git-tag
    index 6145bf5e2..bbee2ad7a 100755
    Binary files a/git-svn and b/git-tag differ