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

17,529

Solution 1

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.)

Solution 2

git log -p --branches --not --remotes

Worked.

Share:
17,529
Justin
Author by

Justin

Updated on June 05, 2022

Comments

  • Justin
    Justin almost 2 years

    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.

    • John Szakmeister
      John Szakmeister over 11 years
      If you want to see the diff for each commit, use git log -p --branches --not --remotes. The -p stands for patch. It'll show you unified diff for each commit.
  • bluehazetech
    bluehazetech almost 8 years
    git diff origin/master..HEAD works if there haven't been any other commits to the remote branch since your last fetch. This solution works regardless of activity on the remote branch. For that reason alone, I prefer this approach for viewing a diff of local commits not yet pushed.