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]
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.
git diff --cached
Add this alias to your .gitconfig:
[alias]
lg = log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\n--abbrev-commit --date=relative
And use the command like this:
> git lg
> git lg -- filename
The output will look almost exactly the same as the gitk output. Enjoy.
If you're using the git GUI (on Windows) under the Repository menu you can use "Visualize master's History". Highlight a commit in the top pane and a file in the lower right and you'll see the diff for that commit in the lower left.
If you use TortoiseGit you should be able to right click on the file and do TortoiseGit --> Show Log
. In the window that pops up, make sure:
'Show Whole Project
' option is not checked.
'All Branches
' option is checked.
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"
git diff -U <filename>
give you a unified diff.
It should be colored on red and green. If it's not, run: git config color.ui auto
first.