git - 如何检查远程 git 存储库 URL 的有效性?

标签 git bash url curl github

在 bash 脚本中,验证 git URL 是否指向有效的 git 存储库以及脚本是否有权从中读取的最简单方法是什么?

应支持的协议(protocol)是git@https://git://。 Curl 在 git:// 协议(protocol)上失败。

git@github.com:UserName/Example.git
https://UserName@github.com/UserName/Example.git
git://github.com/UserName/Example.git

注意:我不是要检查 URL 在语法上是否正确,我需要验证在从 bash 脚本中输入的 URL 位置是否存在存储库。

最佳答案

this issue 所示, 你可以使用 git ls-remote测试您的地址。

If you need to debug the git calls set GIT_TRACE=1. eg:

env GIT_PROXY_COMMAND=myproxy.sh GIT_TRACE=1 git ls-remote https://...

"git ls-remote" is the quickest way I know to test communications with a remote repository without actually cloning it. Hence its utility as a test for this issue.

您可以在“git ls-remote returns 128 on any repo”中看到它用于检测地址问题。

关于git - 如何检查远程 git 存储库 URL 的有效性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9610131/

相关文章:

git - 意外的 `git config --get core.commentChar` 退出代码

linux - 使 linux "Wait"命令等待所有子进程

bash - WGET 保存时使用错误的文件和扩展名,可能是由于 BASH 造成的

bash - 仅显示文件名和文件权限

asp.net-mvc - 是否可以在 ASP.NET MVC 中本地化 URL/路由?

vb.net - 从 URI 启动应用程序 - VB.NET

ruby-on-rails - 将应用程序部署到 Heroku : 'NameError: uninitialized constant Devise'

node.js - 如何从 git 存储库获取通过 NPM 安装的包的提交哈希值?

git - 无法推送到 Git - 一直要求我验证电子邮件

bash - 'status' 是 bash 中的关键字吗?