Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diff in Emacs between version of file in working dir and previous commit in git repo

Tags:

git

emacs

diff

I have a git repository. I edit a file from the repository in Emacs and I want to use ediff in Emacs to see the differences between the text in the buffer visiting the file and a previous commit of the same file (by default the last commit). Is this possible / easy to do?

like image 681
cefstat Avatar asked Nov 25 '10 09:11

cefstat


People also ask

What is the command to show the differences between the last commit and your unstaged files?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit.

What is emacs in git?

Magit is a complete text-based user interface to Git. It fills the glaring gap between the Git command-line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks with just a couple of mnemonic key presses.


Video Answer


2 Answers

Sounds like M-x ediff-revision is what you want. It allows you to refer to revisions using the normal syntax you use for your RCS, such as git.

I see that there's a similar question here

like image 111
brontitall Avatar answered Oct 08 '22 13:10

brontitall


Git is well supported. You should be able to use the normal vc package "C-x v = vc-diff".

like image 45
hpavc Avatar answered Oct 08 '22 14:10

hpavc