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?
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 .
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With