1

When collaborating with others, I often need to check what others have changed in a file since I last worked on it. Is there an easy way in magit to do this? I.e. show the diff between my last own commit and the current version.

I'm aware that magit can show differences between revisions. But tracking down the relevant revisions is the tedious part that I'd like to have automated. I suspect that magit doesn't have the precise feature that I'm describing, but perhaps there is a simple hack using existing magit capabilities that allows me to build a command that does the job.

1 Answer 1

1

EDIT in response to your comment

I am not sure how to retrieve the hash of your own last commit with magit, however (until someone adds that info here), you could simply use the git command directly with shell-command-to-string for that as follows:

(defun my-magit-diff-with-personal-last ()
  (interactive)
  (let ((my-last (string-trim-right
                  (shell-command-to-string "git log -1 --author=Titus --format=\"%H\"")
                  "\n")))
    (magit-diff-range (print (format "HEAD..%s" my-last)))))

Of course you can adapt the example to your exact 'requirements'.

Another way, is to find your last commit in the git log using l -A your name from the magit status buffer. Then press d d to diff with the HEAD.

END EDIT

I am not sure what you mean by 'easy way', but I guess using magit-ediff-compare or magit-diff-range will be easy enough.

1
  • I know magit has the ability to show differences between revisions. But tracking down the relevant revisions is the tedious part that could be automated. I suspect that magit doesn't have the precise feature that I'm describing but perhaps there is a simple hack using existing magit capabilities that allows me to build a command that does the job.
    – tmalsburg
    Nov 30, 2022 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.