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?
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?
Or you could just run git log -p
- it does pretty much the same thing that you want
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.
UPDATE:
Matthieu Moy suggested much better variant:
for rev in $(git rev-list <committish>.. ); do
git difftool ${rev} ${rev}~1;
done
The OLD version of the answer:
I would say you do something like:
git rev-list <commitish>.. | wc -l
or
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)}
c=${c}-1
done
for i in 1 2 3
do
((j=${i}-1))
git difftool HEAD~${i}..HEAD~${j} path/to/file &
done
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.