54

I'm seeking a tool to help when probing a file's history. Specifically, I want to view the entire contents of the file, but be able to step backward and forward in time. Extra joy for decorations indicating the diff from previous rev or some other specified rev.

Currently I use git blame, and can see what changes impacted each current line. Then I have to relaunch a viewer for that file with some particular commit. It's labor intensive, and if a tool already automates this I'd love to use it!

Perforce's timelapse view is the best tool to date I've seen for this task.

Alex Feinman
  • 5,393
  • 1
  • 30
  • 48
Vincent Scheib
  • 17,142
  • 9
  • 61
  • 77
  • 1
    possible duplicate of [Does anyone know a tool for Git similar to SVN Time-Lapse View](http://stackoverflow.com/questions/725827/does-anyone-know-a-tool-for-git-similar-to-svn-time-lapse-view) – Matthieu Moy May 23 '15 at 22:19
  • your question answered my question. I fired up `git blame` and am happy with the result. thanks. – Mark Ch Feb 05 '16 at 10:40

9 Answers9

14

gitk -- filename should do what you want, if you kick up the lines of context in the middle, and scroll up and down through the revisions.

Karl Bielefeldt
  • 47,314
  • 10
  • 60
  • 94
  • Sounds great, though I can't figure out how to view the file and move revisions with it? I only seem to be able to see diffs and – Vincent Scheib Oct 19 '11 at 23:39
  • 2
    There's a setting in the middle of the page called "lines of context." Increase it until it shows the entire file. – Karl Bielefeldt Oct 19 '11 at 23:46
  • Note: Instead of invoking gitk on a certain file, you can also set the file in the GUI: Menu View / Edit view... , then enter the full filename in the box for the list of files on the bottom. – sleske Apr 30 '13 at 14:31
  • 1
    Do you know that is time lapse view at all? – Yola Nov 03 '15 at 13:28
  • this is almost perfect but gitk doesn't keep the line you had selected in view so you have to repeatedly scroll down to it – David Fooks Jul 30 '19 at 16:32
12

Tig, a text mode interface for git, offers a blame view that offers some of this functionality:

  • Step backwards in time to the commit of a given line (b key).
  • Step backwards to the parent commit of a given line (, key).
  • Returning forwards in time to a view you were at previously (< key).

It does not preserve the viewing location when stepping to a parent commit (it seems to when using the line's commit).

Cristian Ciupitu
  • 20,270
  • 7
  • 50
  • 76
Vincent Scheib
  • 17,142
  • 9
  • 61
  • 77
11

Here is a Git Time-Lapse View tool that I have written in Java:

https://github.com/JonathanAquino/git-time-lapse-view

enter image description here

Jonathan Aquino
  • 3,780
  • 1
  • 18
  • 19
8

git gui blame is an option, although it's not as good.

Example for gc_storage from Ansible:

git gui blame --line=155 library/cloud/gc_storage

git gui blame --line=155 library/cloud/gc_storage

Right click a line and select Blame Parent Commit to move back in time, returning to more recent changes with the view history arrow in the top left.

Cristian Ciupitu
  • 20,270
  • 7
  • 50
  • 76
5

Try https://github.com/pomber/git-history which shows full file with beautiful slide-in animations as you move on horizotal timeline:

demo gif

You don't even need to install it, just change the domain on any Github file url!

Weak points, as of this writing:

Beni Cherniavsky-Paskin
  • 9,483
  • 2
  • 50
  • 58
4

If you are using vim, the git-time-lapse plugin could also help you.

It allows you to navigate through history for a file, presenting each commit in vimdiff form, with the commit message in a separate vsplit below.

Cristian Ciupitu
  • 20,270
  • 7
  • 50
  • 76
mpb
  • 43
  • 5
2

I have a Perl script (too big and too general to post as an answer to this question) that grabs a copy of each revision of a specified file in git. (It also works with RCS and CVS).

EDIT : I've finally gotten around to releasing it on Github.

The core of it is this (pseudo-code):

  • Run git log --date=raw -- filename
  • Search the output for commit and Date: lines.
  • For each commit-id:
    • Run git show commit-id ./filename > target-filename

The target-filename is constructed from some combination of the commit-id, the timestamp, and/or a sequential index.

The result might be, for example, a bunch of files like:

foo__001.txt
foo__002.txt
foo__003.txt

where each is a version of foo.txt from the git repository. I can then view each file and/or diff consecutive versions of it.

This doesn't give you everything you're asking for, but it should be a good start.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
2

You could also use something like github if you wanted to - its history view for a particular file shows you a synopsis of when each file was edited and by whom, and gives you handy links to view the diff of that file for that commit, the current version of the file at that commit, etc.

johnny
  • 4,024
  • 2
  • 24
  • 38
  • +1 for GitHub, the Blame view is similar to p4v's time lapse except you can't scrub back and forth through time (although you can look at the Blame view on a file at different revisions). – Bryan Downing Aug 09 '16 at 02:11
0

If you are using Visual Studio, CodeLineage is nice.

https://visualstudiogallery.msdn.microsoft.com/bb3d22aa-29bf-41e1-acc9-92482bee4646

I like that the Git Time-Lapse by Jonathan Aquino shows you the commit comment, but CodeLineage is nice because it integrates in Visual Studio and you can select the two revisions you are comparing, instead of just comparing each revision with its previous revision.

mhenry1384
  • 7,538
  • 5
  • 55
  • 74