View git changes/diffs of local commits not pushed to remote

Justin picture Justin · Sep 26, 2012 · Viewed 14.6k times · Source

I have three Git commits that I committed locally, but have not pushed to GitHub. I would like to view the changes/diffs for all three commits, how do I view all the diffs?

I tried: git log --branches --not --remotes

Which shows me the three commits, but not all the diffs/changes of each.

commit c08fbb72ae6a06e8b2ff3dbbb96fb555a43f4136
Author: Justin <[email protected]>
Date:   Mon Sep 10 18:17:02 2012 -0700

    Updated order of requires in Requires.php

commit 041fe19a48269a8aea2ccf90f53568893d4e0158
Author: Justin <[email protected]>
Date:   Mon Sep 10 17:56:42 2012 -0700

    Checking for app.config.php in Requires.php

commit 61c103a8a122bcde2311d081a8340ee1dd71997c
Author: Justin <[email protected]>
Date:   Mon Sep 10 17:42:20 2012 -0700

    Version bump 0.4.0. See CHANGELOG.md

Thanks for the help.

Answer

Simon Boudrias picture Simon Boudrias · Sep 26, 2012

You could probably use git diff like this:

git diff origin/master..HEAD

assuming that your HEAD is currently pointing to your latest commit. Otherwise, you could just use

git diff origin/master..master

(Of course, change accordingly if your remote isn't origin, or if your branch isn't master.)