How can I view the change history of an individual file in Git, complete details with what has changed?
I have got as far as:
git log -- [filename]
which shows me the commit history of the file, but how do I get at the content of each of the file changes?
I'm trying to make the transition from MS SourceSafe and that used to be a simple right-click
→ show history
.
Summary of other answers after reading through them and playing a bit:
The usual command line command would be
But you can also use either gitk (gui) or tig (text-ui) to give much more human-readable ways of looking at it.
Under debian/ubuntu, the install command for these lovely tools is as expected :
And I'm currently using:
so that I can just type
gdf dir
to get a focussed history of everything in subdirectorydir
.Lately I discovered
tig
and found it very useful. There are some cases I'd wish it does A or B but most of the time it's rather neat.For your case,
tig <filename>
might be what you're looking for.http://jonas.nitro.dk/tig/
With the excellent Git Extensions, you go to a point in the history where the file still existed (if it have been deleted, otherwise just go to HEAD), switch to the
File tree
tab, right-click on the file and chooseFile history
.By default, it follows the file through the renames, and the
Blame
tab allows to see the name at a given revision.It has some minor gotchas, like showing
fatal: Not a valid object name
in theView
tab when clicking on the deletion revision, but I can live with that. :-)To show what revision and author last modified each line of a file:
or if you want to use the powerful blame GUI:
The answer I was looking for that wasn't in this thread is to see changes in files that I'd staged for commit. i.e.
If you are using eclipse with the git plugin, it has an excellent comparison view with history. Right click the file and select "compare with"=> "history"