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