Search code examples
gitgit-commitgit-diffgit-log

How to list unpushed Git commits (local but not on origin)


How can I view any local commits I've made, that haven't yet been pushed to the remote repository? Occasionally, git status will print out that my branch is X commits ahead of origin/master, but not always.

Is this a bug with my install of Git, or am I missing something?


Solution

  • This gives a log of all commits between origin/master and HEAD:

    git log origin/master..HEAD
    

    When HEAD is on the master branch, this gives a log of unpushed commits.


    Similarly, to view the diff:

    git diff origin/master..HEAD