As a system administrator, I spend a certain amount of time spelunking through the history of some particular file in Git because I'm trying to understand how it evolved, what it used to do, when something was introduced or removed, and so on. There are two ways to do this, either through a straightforward history of a file or through what I'll call the blame history of a file, where you start with 'git blame' and then ask for what the file looked like before a particular change of interest. I'm pretty sure I first saw the blame history view on Github, where it's a signature feature of their blame view (in the form of the 'Blame prior to change ...' option).
In GNU Emacs you can look through a file's straight history with git-timemachine , or by using 'n' and 'p' in VC 's annotated view of the file ( C-x v g ); if you're using the annotated view purely to page through versions of the file, you may want to use 'v' to turn off the commit information on the left side. In Magit , looking through versions of a file over time is done by starting with
magit-blob-previous
(often 'C-c M-g p', cf ), and then 'p' and 'n' (and 'q').
Both VC and Magit can provide a blame history view of a file, and which one is easier to use will depend on your views. In VC , this is done through
vc-annotate
, C-x v g normally, and in Magit it is done through (of course)
magit-blame
(which is also accessible through git-timemachine and Magit's blob view of a past version of the file, which will let you start the blame at a particular version), or you may want to jump directly to
magit-blame-addition
. In Magit's blaming mode you jump to the file before a particular change with 'b' and return with 'q', and you can cycle through the blame display styles with 'c'.
In VC 's annotate mode you jump to the (annotated) file before a particular change with 'a' and you can turn the 'git blame' style leading information on and off with 'v'. You can also jump to the file as of a particular change with 'j', which is potentially handy and which I don't think Magit supports directly (although you can copy the commit hash with M-w and then use
magit-find-file
or friends). However, as far as I know VC 's annotate mode doesn't have an easy way to return to the blame view you were at before you used 'a' or 'j'. Moving through blame history in VC 's annotate mode appears to be mostly a one way trip.
Neither VC nor Magit quite provides the Github like experience. Magit lets you navigate back, the way Github does, but it doesn't have a 'git blame' style display of the commit information on the left side. VC has the 'git blame' style display but not navigating back. For my purposes I probably care more about navigating back in the case of mistakes than blame style display, so I think I'll turn first to Magit .
( git blame can more or less do this from the command line, since you can start it for a file from a specific version. This gives you both the VC 'j' and 'a' commands; for 'j' you use the commit that 'git blame' reports for a line, and for 'a' you use '<commit>~' for one before that commit.)
(This is the kind of entry I write because it pushes me to do a certain amount of research and then write down what I've learned for future use.)