Step through a file's history in git; similar to p4v timelapse

Git

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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).

Solution 3 - Git

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

Solution 4 - Git

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.

Solution 5 - Git

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.

Solution 6 - Git

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:

Solution 7 - Git

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.

Solution 8 - Git

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.

Solution 9 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVincent ScheibView Question on Stackoverflow
Solution 1 - GitKarl BielefeldtView Answer on Stackoverflow
Solution 2 - GitVincent ScheibView Answer on Stackoverflow
Solution 3 - GitJonathan AquinoView Answer on Stackoverflow
Solution 4 - GitCristian CiupituView Answer on Stackoverflow
Solution 5 - GitmpbView Answer on Stackoverflow
Solution 6 - GitBeni Cherniavsky-PaskinView Answer on Stackoverflow
Solution 7 - GitKeith ThompsonView Answer on Stackoverflow
Solution 8 - GitjohnnyView Answer on Stackoverflow
Solution 9 - Gitmhenry1384View Answer on Stackoverflow