使用git repo url查询存储库是否存在



我在google上搜索过,他们说"git ls-remote git-url"可以知道git repo是否存在

但是我有一个问题,当使用这个命令检查github不存在的https git url。

例如,当我运行下面的命令时,它将需要输入用户名和密码。
$ git ls-remote https://github.com/grant/noexisted.git

我只想检查repo是否存在,我调用了"git ls-remote"命令那么如何跳过这个自动shell提示呢?

为什么不直接发出HTTP请求,然后查找404呢?

例如,可以使用wget命令行实用程序:

$ wget https://github.com/grant/noexisted.git --no-check-certificate -o /dev/null
$ echo ?

打印8,而

$ wget https://github.com/mikeobrien/HidLibrary --no-check-certificate -o /dev/null
$ echo $?

this打印0 (success).

我不熟悉Ruby,但我确信它将是微不足道的HTTP请求和检查404(未找到)或200(成功)。

最新更新