检查 master 分支是否有新的提交

Check if master branch have new commits

哪里有更好的理解方式是在什么时候使用 git fetch 获取任何新提交:

git fetch origin --dry-run -v 2>&1| grep 'master'| grep 'up to date'

然后,如果输出如下:

= [up to date]      master     -> origin/master

我不需要进行实际提取,如果不需要,我会进行提取。

我现在正在使用这种方法,但我想知道哪里有更好的解决方案?

我也想检查类似的 hg - 哪里有办法做到这一点?

您可以使用 git fetch --dry-run 检查远程是否有新的更改要获取。它将

show what would be done without making any changes

.

您也可以使用 hg incoming 检查是否有要提取的更改。

Mercurial provides the hg incoming command to tell us what changes the hg pull command would pull into the repository, without actually pulling the changes in.