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]
If you prefer to stay text-based, you may want to use tig.
Quick Install:
# apt-get install tig
$ brew install tig
Use it to view history on a single file: tig [filename]
Or browse detailed repo history: tig
Similar to gitk
but text based. Supports colors in terminal!
You can use vscode with GitLens, it's a very powerful tool.
After installed GitLens, go to GitLens tab, select FILE HISTORY
and you can browse it.
To show what revision and author last modified each line of a file:
git blame filename
or if you want to use the powerful blame GUI:
git gui blame filename
Summary of other answers after reading through them and playing a bit:
The usual command line command would be
git log --follow --all -p dir/file.c
But you can also use either gitk (gui) or tig (text-ui) to give much more human-readable ways of looking at it.
gitk --follow --all -p dir/file.c
tig --follow --all -p dir/file.c
Under debian/ubuntu, the install command for these lovely tools is as expected :
sudo apt-get install gitk tig
And I'm currently using:
alias gdf='gitk --follow --all -p'
so that I can just type gdf dir
to get a focussed history of everything in subdirectory dir
.
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/
You can use
git log -p filename
to let git generate the patches for each log entry.
See
git help log
for more options - it can actually do a lot of nice things :) To get just the diff for a specific commit you can
git show HEAD
or any other revision by identifier. Or use
gitk
to browse the changes visually.