Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.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
Git 如何卷曲或设置url的内容_Git_Curl_Gerrit - Fatal编程技术网

Git 如何卷曲或设置url的内容

Git 如何卷曲或设置url的内容,git,curl,gerrit,Git,Curl,Gerrit,我想从gerrit url下载文件,比如 https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain;f=model/ietf/ietf-yang-types/src/main/yang/ietf-yang-types.yang;hb=HEAD 我用wget和curl尝试了我的运气,但是没有在上面的url下载原始内容,我得到了html内容,但是我只想在我们开始https://raw.githubusercontent.

我想从gerrit url下载文件,比如

https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain;f=model/ietf/ietf-yang-types/src/main/yang/ietf-yang-types.yang;hb=HEAD
我用wget和curl尝试了我的运气,但是没有在上面的url下载原始内容,我得到了html内容,但是我只想在我们开始
https://raw.githubusercontent.com

我使用的命令:

 wget https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain;f=model/ietf/ietf-yang-types/src/main/yang/ietf-yang-types.yang;hb=HEAD
 curl https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain;f=model/ietf/ietf-yang-types/src/main/yang/ietf-yang-types.yang;hb=HEAD
我得到了相同的html输出,但我只想要文件的原始内容。

PHP
您需要在URL周围加引号。
字符可能会绊倒你-外壳将读取到那里,然后处理
作为命令的结尾

尝试:

<?php    
$url = 'https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain;f=model/ietf/ietf-yang-types/src/main/yang/ietf-yang-types.yang;hb=HEAD';
$content = file_get_contents($url);
wget 'https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain;f=model/ietf/ietf-yang-types/src/main/yang/ietf-yang-types.yang;hb=HEAD'
curl 'https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain;f=model/ietf/ietf-yang-types/src/main/yang/ietf-yang-types.yang;hb=HEAD'