使用脚本检查git分支是否在另一个分支之前 [英] Check if a git branch is ahead of another using a script

查看:123
本文介绍了使用脚本检查git分支是否在另一个分支之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有branch1branch2,我想要某种类型的东西:

I have branch1 and branch2 and I want some sort of:

git branch1 isahead branch2

这将显示branch1是否具有branch2不具有的提交(并可能也指定那些提交).我无法检查导致branch2 是否在branch1之前的(具有branch1没有的提交).

That will show if branch1 has commits that branch2 doesn't have (and possibly specify those commits too). I can't check diff cause branch2 is ahead of branch1 (has commits that branch1 doesn't have).

有办法吗?我浏览了git diff却找不到任何东西

Is there a way? I looked through git diff and couldn't find anything

推荐答案

您可以使用

git log branch2..branch1

如果branch1branch2之前没有提交,则输出为空.

If branch1 has no commit ahead of branch2, output will be empty.

您也可以使用git rev-list --count branch2..branch1

这将显示前面的提交次数

This will show the number of commits ahead

来源

这篇关于使用脚本检查git分支是否在另一个分支之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆