tags:

views:

740

answers:

5

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?

A: 
git diff origin

Assuming your branch is set up to track the origin, then that should show you the differences.

git log origin

Will give you a summary of the commits.

mopoke
+3  A: 

You can do this with git log:

git log origin..

Assuming that origin is the name of your upstream, leaving off any revision name after .. implies HEAD, which lists the new commits that haven't been pushed.

Greg Hewgill
Whenever I see an answer with `git log` and "2-dots-not-3", it always remind me of http://stackoverflow.com/questions/53569/how-to-get-the-changes-on-a-branch-in-git/53573#53573 ;)
VonC
What a coincidence, me too!
Greg Hewgill
+1  A: 

It is not a bug. What you probably seeing is git status after a failed auto-merge where the changes from the remote are fetched but not yet merged.

To see the commits between local repo and remote do this:

git fetch

This is 100% safe and will not mock up your working copy. If there were changes git status wil show X commits ahead of origin/master.

You can now show log of commits that are in the remote but not in the local:

git log HEAD..origin
Igor Zevaka
+9  A: 
git log origin/master..HEAD
Peter B
This did it for me - for some reason git log origin.. by itself was throwing an error.Looks like I also had a problem with the way my local branch was configured - once I made the changes I found here: https://wincent.com/blog/your-branch-is-ahead-of-origin-master-by-1-commit…the problem was resolved, and I could use git status again to see what I wanted.
joshbuhler
+3  A: 

If you want to see all commits on all branches that aren't pushed yet, you might be looking for something like this:

git log --branches --not --remotes

And if you only want to see the most recent commit on each branch, and the branch names, this:

git log --branches --not --remotes --simplify-by-decoration --decorate --oneline

cxreg