Git diff tool on every commit?

I would like to run git difftool HEAD~3.. path/to/file and have git open the difftool for each of those three commits so that I can see a side-by-side view of each commit.

How would I go about getting git-difftool to do that?

  • How to compare two files not in repo using git
  • Git diff for copied files
  • How can I view the output of `git show` in a diff viewer like meld, kdiff3, etc
  • Differences for a certain folder between git branches
  • Why can't I do git diff on this specific commit?
  • Git diff for added file
  • git pull merge misunderstanding
  • bash: msbuild: command not found
  • Moved folder into submodule, now getting “Untracked files would be overwritten” message
  • Integrate Dreamweaver with Git on OS X
  • Unable to determine upstream SVN information from HEAD history
  • What is the difference between “py” and “pyc” in .gitignore notation?
  • 5 Solutions collect form web for “Git diff tool on every commit?”

    This would accomplish what you describe:

    git difftool HEAD~3 HEAD~2 path/to/file
    git difftool HEAD~2 HEAD~1 path/to/file
    git difftool HEAD~1 HEAD path/to/file

    Want to automate this process? Is it always three commits? Do you want a three-way merge?


    If the answers are yes-yes-no, the solution will be:

    for i in {3..1}; do
      git difftool HEAD~$i HEAD~$((i-1)) path/to/file


    If the answers are yes-no-yes, it is essentially what @ruffin asks here. See my answer there.

    Or you could just run git log -p – it does pretty much the same thing that you want

    for i in 1 2 3
      git difftool HEAD~${i}..HEAD~${j} path/to/file &

    A slightly different approach:

    1) Perform an interactive rebase

    git rebase -i <commitish>

    2) Mark all your commits for edit

    3) For each commit run

    git difftool HEAD~1

    4) Go to the next commit and repeat step 3

    git rebase --continue

    The added advantage is that if you see a problem in the review, you have already checked out the commit that you want to fix.


    Matthieu Moy suggested much better variant:

    for rev in $(git rev-list <committish>.. ); do
        git difftool ${rev} ${rev}~1;

    The OLD version of the answer:

    I would say you do something like:

    git rev-list <commitish>.. | wc -l


    git log --oneline <commitish>.. | wc -l

    This will calculate how many revision you have between your <commitish> and HEAD.

    Then using this number you can automatically run through the commits to see the diffs

    c=`git log --online <commitish>.. | wc -l`
    while ! ${c} eq 0 ; do
    git difftool HEAD~${c} HEAD~${($c-1)}
    Git Baby is a git and github fan, let's start git clone.