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?
This would be especially useful since I often switch to feature branches and would like to see such logs for those, too.
CodePudding user response:
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