Wednesday, April 29, 2009

Git, Python, Emacs: Viewing Old Versions of File

Here is a small utility written in Python, Pymacs for Emacs while working with Git. While you are viewing a file in Emacs, if you issue a M-x githist-do-show-version it will prompt you for a number, and the script will go back that many numbers back on master branch - it basically runs
git show master~[number]:path/to/file/starting/from/dotgit/File.ext
and show you the contents of that file in a new buffer. To install the code see here, drop it under site-lisp and change your .emacs as
(pymacs-load "/usr/share/emacs/22.2/site-lisp/githist")

(defun githist-do-show-version(num)
(interactive "nHow many commits back: ")
(githist-show-version num)
)