This will do what you want, provided you have remote tracking configured for your branch:
git log ..@{u}
It will show all the commits on remotes/branch which are not already on your local branch. If you want to also see your local commits which have not been pushed, use three dots:
git log ...@{u}
Or if you want to see only your local commits which have not been pushed as of your last fetch, put the two dots after @{u}:
git log @{u}..
Explanation:
@{u} is shorthand for `HEAD@{upstream}
master@{upstream} means the remote tracking branch for my local 'master' branch. master@{upstream} is the same as origin/master if your master branch is tracking the remote branch named master on the remote named origin.
- If you omit the branch name (e.g.
master) then your current branch is used instead.
upstream can be abbreviated to u in this case. So @{u} is the same as master@{upstream} if your current branch is named master.
.. is used to specify a range of commits.
A..B is the same as ^A B which means show me all the commits in B but exclude those in A. It can also be written B --not A.
- If you omit either reference, like
A.. or ..B, then the omitted reference is presumed to be HEAD.
- You can see what your upstream tracking is configured to with
git rev-parse --symbolic-full-name @{u}
- You can set your upstream tracking explicitly with
git branch --set-upstream-to=origin/master
You can find all the details about revision specifications like this in the Git man pages:
git help revisions
Or
man gitrevisions