Compare foo.bar from two different branches in MAGIT
Building up from @dominik-schrempf 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 :
Start from any Magit buffer with a list of commits
(like any commit log or the recent commits list in the Magit status buffer) :Select the commits using text selection
1a. Have the cursor on one end of the wanted commits
1b. Toggle text selection
C-SPC
(orV
if you use evil-mode)1c. Move your cursor over to the other end of the wanted commits
d
to open the diff popupd
to open the dwim buffer orr
for diff range (They do mostly the same thing in this case, I think)
For the text selection part, it is the set-mark-command
function of Emacs.
You can learn more about it by using Emacs' integrated help system:
C-h f
followedset-mark-command
, or;- from the
execute-extended-command
(which should be your second best friend after the help prefix keyC-h
seen above)M-x
followed bydescribe-function
followed byset-mark-command
.
These two paths are equivalent as every Emacs keybindings is calling a function.
In short, use the help prefix and the execute-extended-command
often, especially when starting using Emacs.
I use magit to complement vc
. vc
already has this functionality C-u C-x v =
Just wanted to note that this is now directly possible with magit
.
In the Magit status buffer, type d
to open up the diff popup.
Then limit the diff to your file of interest with =f
and the file name.
Finally, do a diff range r
and type in the branch that you want to compare to (one can also type in a specific commit on the same branch, see a similar question).