Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs Magit: how can I see differences between a given branch and unstaged changes?

Tags:

emacs

magit

With git I can see the differences in a file relative to any other past commit as:

git diff commit file_name

This shows me the differences in file_name between the version in commit against my current unstaged changes.

With Magit I can choose a given commit with . in the log and compare it with another commit with =. However I do not see my unstaged changes in the log so how can I select them to make the comparison?

Thank you in advance.

like image 601
Alejandro Avatar asked Oct 18 '25 19:10

Alejandro


1 Answers

When in the main magit view (which you get after calling magit-status), you can press d to get a menu of all diff commands. Then press r (range) to diff against a specific commit (which is prompted in the minibuffer).

If you want the exact equivalent to your git command line and limit the diff to specific files, then press -- before r.

The complete sequence to get an equivalent of git diff commit file_name is thus :

  • d
  • --file_nameRET
  • rcommitRET
like image 55
François Févotte Avatar answered Oct 20 '25 15:10

François Févotte