Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用URL获取远程用户的合格Git URL。<;基础>;。代替?_Git - Fatal编程技术网

如何使用URL获取远程用户的合格Git URL。<;基础>;。代替?

如何使用URL获取远程用户的合格Git URL。<;基础>;。代替?,git,Git,我使用Git存储库,使用该方案将实际的repo URL存储在我的~/.gitconfig中。我使用的一个应用程序尝试使用git config找出对repo的访问方案(ssh、http等),但失败了,因为输出如下所示: # git config --get remote.origin.url gerrithost:department/project 在my~/.gitconfig中设置gerrithost的位置: 应用程序希望git config--get remote.origin.url的

我使用Git存储库,使用该方案将实际的repo URL存储在我的~/.gitconfig中。我使用的一个应用程序尝试使用git config找出对repo的访问方案(ssh、http等),但失败了,因为输出如下所示:

# git config --get remote.origin.url
gerrithost:department/project
在my~/.gitconfig中设置gerrithost的位置:

应用程序希望git config--get remote.origin.url的输出如下所示:

ssh://machine.dn.tld:29418/department/project
GitRemote-v显示解析的URL,但我必须解析输出以获得正确的remote and字段


是否可以使用git config(或其他工具之一)获取解析的URL,或者我必须恢复为git remote编写解析器?

正如Stefan Nä我们在评论中已经解释的那样,您要查找的命令是

git ls-remote --get-url

有关更多信息,请查看。

我刚刚测试过,在尝试
git-remote-v
(使用git 1.9.1或1.9.2)时,没有看到任何分辨率。我仍然看到
xxx:repo
。这意味着,如果你的应用程序看到一个包含“
:/
”的url(并且没有“
:/
”),它可以假设它的url方案是ssh。@VonC现在实际上检查协议(ssh)和端口(29418),以验证它是Gerrit url。这不是我的应用程序,如果我删除端口检查,我不确定上游是否会接受修补程序:/我理解。我只是很惊讶你提到了
git remote-v
解决了任何问题:它不在我这边。
git ls remote--get url
?创建一个答案将非常好。目前,这个问题在未回答的问题列表中显得相当重要。
git ls-remote --get-url