How can I get the diff between two commits of the same file using magit
?
Directly form git
one can do this. But I don\'t k
One way to go is to use vc
as suggested by this related answer - in particular C-u C-x v =. However, this return a buffer without the possibility to (un)fold chunks.
In case anyone stumbles across this now, it is now possible to do this in magit (I do this from magit-log but you can probably do it from elsewhere, too):
d
to open the magit-diff-popup=f
to specify the file you want to view (enter path relative to the project root dir)r
to do a diff range. You will be asked for the commit range, for example, 4abcde2..HEAD
. Alternately, if you highlight the range of commits in magit-log, the range will be set for you automatically with no prompt.This way, you end up in a magit-diff buffer complete with highlighting and code folding.
Building up from @cdidyk answer, it is also (now) possible to select the range of the diff with text selection to go quicker than typing the hashes of the commits.
So a quicker (and more visual) sequence could be :
C-SPC
(or V
if you use evil-mode)=f
to specify the file (path relative to the project root folder)d
to open the diff popupd
to open the dwim buffer or r
for diff range (They do mostly the same thing in this case, I think)