How to see the changes between two commits without commits in-between?

How do you make git diff only show the difference between two commits, excluding the other commits in-between?

  • How do I build git on Red Hat Enterprise Linux 3?
  • Error starting Git Bash in windows 7
  • How to deal with git apply-mailbox conflicts when reconstructing a repo
  • A way to keep a shallow git clone just minimally up to date?
  • eclipse error cloning git repository from tfs authentication not supported
  • Delete everything and upload new version
  • Why git difftool does not open vimdiff in case of conflicts?
  • Git pull origin/master branch to local/master, when in local/develop
  • Using git submodules in a git-svn project
  • Disable automatic commit of changed files in Visual Studio 2013 to git
  • Different Config Files in GitHub Repo Branch
  • Why has git-filter-branch not rewritten tags?
  • 8 Solutions collect form web for “How to see the changes between two commits without commits in-between?”

    you can simply pass the 2 commits to git diff like :

    -> git diff 0da94be  59ff30c > my.patch
    -> git apply my.patch

    Asking for the difference /between/ two commits without including the commits in-between makes little sense. Commits are just snapshots of the contents of the repository; asking for the difference between two necessarily includes them. So the question then is, what are you really looking for?

    As William suggested, cherry-picking can give you the delta of a single commit rebased on top of another. That is:

    $ git checkout 012345
    $ git cherry-pick -n abcdef
    $ git diff --cached

    This takes commit ‘abcdef’, compares it to its immediate ancestor, then applies that difference on top of ‘012345’. This new difference is then shown – the only change is the context comes from ‘012345’ rather than ‘abcdef’s immediate ancestor. Of course, you may get conflicts and etc, so it’s not a very useful process in most cases.

    If you’re just interested in abcdef itself, you can do:

    $ git log -u -1 abcdef

    This compares abcdef to its immediate ancestor, alone, and is usually what you want.

    And of course

    $ git diff 012345..abcdef

    gives you all differences between those two commits.

    It would help to get a better idea of what you’re trying to achieve – as I mentioned, asking for the difference between two commits without what’s in between doesn’t actually make sense.

    To compare two git commits 12345 and abcdef as patches one can use the diff command as

    diff <(git show 123456) <(git show abcdef)
    git diff <a-commit> <another-commit> path


    git diff commit1 commit2 config/routes.rb

    It shows the difference on that file between those commits.

    Suppose you want to see the difference between commits 012345 and abcdef. The following should do what you want:

    $ git checkout 012345
    $ git cherry-pick -n abcdef
    $ git diff --cached

    Let’s say you have this

    B    A0
    |    |
    C    D
    \   /

    And you want to make sure that A is the same as A0.

    This will do the trick:

    $ git diff B A > B-A.diff
    $ git diff D A0 > D-A0.diff
    $ diff B-A.diff D-A0.diff

    What about this:

    git diff abcdef 123456 | less

    It’s handy to just pipe it to less if you want to compare many different diffs on the fly.

    Actually I haven’t found a really good solution for this to do automatically, but a hacky solution that gives you exactly what you want is this;

    1. make a copy of the source directory (copy dir A to dir A-copy),
    2. use git to checkout revision (with force option) of that old commit you want to start with,
    3. copy those backed up files into original (copy dir A-copy onto dir A, except for .git hidden files).
    4. the diff to commit now will include all your changes summed up over all the commits in-between.
    Git Baby is a git and github fan, let's start git clone.