[英]How to show log between current branch and its remote counterpart
有時從遠程存儲庫獲取后,我看到我的分支落后了:
> 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)
在更新我的本地分支之前,我想查看我將要獲得的日志。 我可以使用
> git log develop..origin/develop
由於我已經在develop
分支上,有沒有辦法用更少的輸入來完成上述操作? 也就是說,不提供本地和遠程分支名稱?
這將特別有用,因為我經常切換到功能分支並且也希望查看這些日志。
是的,一個簡短且與分支無關的方法是使用@{upstream}
構造:
git log ..@{u}
(注意:由於此處省略了范圍的第一部分,因此暗示了HEAD
,但完整的詳細語法將是HEAD..HEAD@{upstream}
。)
當然,將它作為alias.behind
(例如)非常方便,因為它會使用你所在的任何分支。
評論后編輯:我添加了有用的對應alias.ahead
來檢查即將被推送的提交(有一個問題:雖然@{upstream}
指的是您的配置將從中提取的遠程分支,但在配置中設置的分支是推送到@{push}
( 文檔))。 在某些特定的 3 向設置中,它們可能會有所不同,但在大多數簡單的工作流程中,它們都指向同一個遙控器的同一個分支。 但以防萬一。
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.