View the change history of a file using Git versioning

Question

How do I view the history of an individual file with complete details of what has changed?

git log -- [filename] shows me the commit history of a file, but how do I see the file content that changed?

Answer

This lets Git generate the patches for each log entry:

git log -p -- filename

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, use

git show HEAD

or specify any other revision by identifier.


To browse the changes visually:

gitk

Is there a way to make git pull automatically update submodules?

Git: list only "untracked" files (also, custom commands)