Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to show log between current branch and its remote counterpart

Sometimes after fetching from remote repository I see my branch is behind:

> git status
On branch develop
Your branch is behind 'origin/develop' by 7 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Before updating my local branch I would like to see the log of what I’m about to get. I can do it using

> git log develop..origin/develop

Since I’m already on the develop branch, is there a way to do the above with less typing? That is, without providing local and remote branch names?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This would be especially useful since I often switch to feature branches and would like to see such logs for those, too.

>Solution :

Yes, a short and branch-agnostic way is to use the @{upstream} construct :

git log ..@{u}

(Note : since the first part of the range is omitted here, HEAD is implied, but the full verbose syntax would be HEAD..HEAD@{upstream}.)

And of course it’s very handy to have it as an alias since it’ll use whatever branch you’re on

git config --global alias.logr 'log ..@{u}'

git logr
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading