Update
As noted by amalloy, recent git versions support the search for the appropriate tracking branch for a given branch, providing "branchname @ {upstream}" (or "branchname @ {u}" or "@ {u}" for the HEAD tracking branch). This effectively undoes the script below. You can do:
git rev-list @{u}.. git rev-list --left-right --boundary @{u}... gitk @{u}...
etc .. For example, I have git q with the alias git log --pretty='...' @{u}.. to show that I have "queued", ready to click.
original answer
There seems to be no easy way to find the tracking branch at all, without parsing more git config than is practical in several shell commands. But for many cases this will go a long way:
Another, rougher approach:
git rev-list HEAD --not --remotes
Jamessan's answer explains how to find the relative differences between $ tracking_branch and HEAD using git rev-list . One fun thing you can do:
git rev-list --left-right $tracking_branch...HEAD
(note the three points between $ tracking_branch and HEAD). This will show the commit on both βshouldersβ with a distinctive front sign: β<β for commit on $ tracking_branch and β>β for commit on HEAD.
araqnid Jun 03 '10 at 22:01 2010-06-03 22:01
source share