Reputation: 2386
I figured out I can show old versions of a file using 'git log filename' to show the commits, and then use 'git show commit-id:filename' for the old version. But it just puts it in less.
I would like to be able to view this in emacs, so I can navigate as I'm used to and so that there is syntax highlighting. I found out I can't set the git core.pager to emacs since emacs cannot read from stdin.
Does anyone know how I could do this? Or do you have another good way of checking old versions of files?
Upvotes: 33
Views: 18713
Reputation: 438
Using the following Vim command, one can view a previous version of a file without having to cleanup anything afterward.
git show commit-id:filename | vim - -n
Explanation: The dash argument of the vim command makes vim load whatever comes in from standard input. The -n option suppresses the creation of swap files.
Upvotes: 8
Reputation: 31
Emacs package git-timemachine lets you step back and forth through git revisions of a file:
https://github.com/pidu/git-timemachine
Upvotes: 3
Reputation: 655
If you are using bash
, you can use Process Substitution.
gvim <(git show commit-id:filename)
Upvotes: 9
Reputation: 43750
Just use >
and put it into a file that you can open in emacs.
git show commit-id:filename > oldfile
Then open the file in emacs.
Upvotes: 38