How do I view previous diff commits using Git?

GitDiff

Git Problem Overview


How do I view previous diff commits using Git?

I have a file that I've made several commits on, but I want to view previous versions of the file AND its diff's at different stages. Seeing where I made mistakes and how I fixed them is really helping my code. By the way, I'm using Tower as a GUI on top of Git.

Git Solutions


Solution 1 - Git

git log --full-diff -p your_file_path

Check out:
http://git-scm.com/docs/git-log

Solution 2 - Git

You need git log. If you were interested in file SOMEFILE use

$ git log -p SOMEFILE

The -p option displays the patch which is probably the diff you are looking for.

Solution 3 - Git

If you don't want to specify a particular file, and see the diff for all files changed, just use

$ git log -p

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
QuestionlampShadeView Question on Stackoverflow
Solution 1 - GitAhmishView Answer on Stackoverflow
Solution 2 - GitBenjamin BannierView Answer on Stackoverflow
Solution 3 - GitSparhawkView Answer on Stackoverflow