有没有办法在不克隆的情况下查找远程 Git 服务器上是否存在 commit/sha

Is there a way to find if a commit/sha present on remote Git server without cloning

目前我使用 git ls-remote 检查 Gerrit 服务器上是否存在一些更改。但并非所有更改都可以通过这种方式进行检查,尤其是未出现在 git ls-remote 输出中的合并。

如何在不克隆存储库的情况下检查 Git 服务器上是否存在更改。我知道 git -r --contains 可以在存储库中使用。

由于 gerrit 在标签中,我假设您使用的是 Gerrit。

对于已推送审核的提交 (refs/for/foo),您可以使用 gerrit query or Query Changes 检查它是否在服务器上。

对于任何提交,如果您有权访问 Gerrit 服务器并且知道存储库名称,则可以使用 ssh 到 运行 git 命令(git rev-parsegit log) 在 Gerrit 存储库中。

ssh $username@$gerritserver git --git-dir=$path_to_repo.git rev-parse $commit