简体   繁体   English

如何在当前分支与其远程分支之间显示日志

[英]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?由于我已经在develop分支上,有没有办法用更少的输入来完成上述操作? 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.这将特别有用,因为我经常切换到功能分支并且也希望查看这些日志。

Yes, a short and branch-agnostic way is to use the @{upstream} construct :是的,一个简短且与分支无关的方法是使用@{upstream} 构造

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} .) (注意:由于此处省略了范围的第一部分,因此暗示了HEAD ,但完整的详细语法将是HEAD..HEAD@{upstream} 。)


And of course it's very handy to have it as alias.behind (for example) since it'll use whatever branch you're on.当然,将它作为alias.behind (例如)非常方便,因为它会使用你所在的任何分支。

Edit after comments : I added the useful counterpart alias.ahead to check commits about to be pushed (there's a catch : while @{upstream} refers to the remote branch where your config will pull from , the branch set in config to push to is @{push} ( doc )).评论后编辑:我添加了有用的对应alias.ahead来检查即将被推送的提交(有一个问题:虽然@{upstream}指的是您的配置将从中提取的远程分支,但在配置中设置的分支是推送到@{push}文档))。 In some specific 3-way settings, these may differ, but in most simple workflows both point to the same branch of the same remote.某些特定的 3 向设置中,它们可能会有所不同,但在大多数简单的工作流程中,它们都指向同一个遥控器的同一个分支。 But it's just in case.但以防万一。

git config --global alias.behind 'log [any format option you prefer] ..@{u}'
git config --global alias.ahead 'log [any format option you prefer] @{push}..'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当前分支落后于其远程分支 - Current branch is behind its remote counterpart git push错误:当前分支位于其远程对应对象的后面 - git push error: current branch is behind its remote counterpart 如何解决GitHub消息,其中显示当前分支的提示位于其远程对应的后面? - How do I resolve a GitHub message that says the tip of my current branch is behind its remote counterpart? 推送到远程失败,因为“当前分支的尖端位于其远程对应部分之后” - Pushing to remote fails because “tip of your current branch is behind its remote counterpart” GitLab 更新被拒绝,因为您当前分支的尖端落后于其远程对应分支 - GitLab Updates were rejected because the tip of your current branch is behind its remote counterpart GitHub更新被拒绝,因为当前分支的提示位于其远程对应的后面 - GitHub updates were rejected because the tip of current branch is behind its remote counterpart Git 推送错误“您当前分支的提示落后于其远程对应分支” - Git push error "tip of your current branch is behind its remote counterpart" 更新被拒绝,因为你当前分支的尖端落后于它的远程分支 - Updates were rejected because the tip of your current branch is behind its remote counterpart 如何修复Git中的问题:“更新被拒绝,因为推送的分支提示位于其远程对应的后面” - How to fix issue in Git: “Updates were rejected because a pushed branch tip is behind its remote counterpart” 由于远程副本后面的当前分支,推送到裸存储库被拒绝 - Pushing to a bare repository is rejected due to current branch behind remote counterpart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM