See exact divergence/commits between local and remote Git repo

Uzbekjon picture Uzbekjon · May 2, 2012 · Viewed 10k times · Source

Setup: 3 git repos - on github, local and on staging server.

I develop locally, push it to github and staging server pulls.

I don't work nor commit changes on staging server, but I must have done so long time ago. Because now I get the following message when I do git status (on staging server):

On branch SOME_BRANCH
Your branch and 'origin/SOME_BRANCH' have diverged,
and have 4 and 32 different commit(s) each, respectively.

My question is: how do I see those exact 4 commits that are not at origin?

Answer

CharlesB picture CharlesB · May 2, 2012
git rev-list origin..HEAD

This lists the commits in your branch (HEAD) that are not in origin.