Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 356
Dale Forester Avatar asked Jul 26 '12 16:07

Dale Forester


People also ask

How can I see the diff of a commit?

To see the diff for a particular COMMIT hash, where COMMIT is the hash of the commit: git diff COMMIT~ COMMIT will show you the difference between that COMMIT 's ancestor and the COMMIT .

Does git diff show all changes?

The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.

What is the default git diff tool?

The default Diff Tool is vimdiff. Specifying a Diff Tool affects the git difftool command. The command git diff still performs diffing on the command-line.


1 Answers

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?

Update:

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
done

Update:

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

like image 170
Antony Hatchkins Avatar answered Oct 14 '22 08:10

Antony Hatchkins