Curl 无法使用命令行从gitlab下载文件

Curl 无法使用命令行从gitlab下载文件,curl,command-line,gitlab,wget,okta,Curl,Command Line,Gitlab,Wget,Okta,我有一个gitlab的内部部署: 我想通过命令行下载“我想要的文件”。它包含配置内容 我已经试过了: curl -o https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file wget https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file

我有一个gitlab的内部部署:

我想通过命令行下载“我想要的文件”。它包含配置内容

我已经试过了:

curl -o https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file

wget https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file
curl -OL https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file

wget https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file```

curl 'Private-Token: my_private_token' https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file
然后我单击“永久链接”并再次尝试:

curl -o https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file

wget https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/master/my_wanted_file
curl -OL https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file

wget https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file```

curl 'Private-Token: my_private_token' https://gitlab.corp.mycompany.com/project/account/configfile/repo/blob/long_alphanumeric_numer/my_wanted_file
使用curl--header'Private Token:my_Private_Token'加上url,返回以下消息:

<html><body>You are being 
<a href="https://gitlab.corp.my_company.com/users/sign_in">redirected</a>.</body></html>
您正在
.
在所有情况下,我都会得到一个包含java脚本内容的奇怪文件,但从未得到gitlab中当前显示的配置文件内容

我认为让大家知道我正在通过okta连接到这个私有gitlab部署是很重要的。不确定这是否在中间引入了一些噪声,因此需要提供不同的命令。
您能提供建议吗?

对于这种情况,最好使用Gitlab API,特别是从存储库获取文件:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.corp.mycompany.com/api/v4/projects/<project_id>/repository/files/my_wanted_file?ref=master"
curl--header“PRIVATE-TOKEN:”https://gitlab.corp.mycompany.com/api/v4/projects//repository/files/my_wanted_file?ref=master"

按照以下步骤创建您的个人令牌。

对于这种情况,最好使用Gitlab API,特别是从存储库获取文件:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.corp.mycompany.com/api/v4/projects/<project_id>/repository/files/my_wanted_file?ref=master"
curl--header“PRIVATE-TOKEN:”https://gitlab.corp.mycompany.com/api/v4/projects//repository/files/my_wanted_file?ref=master"

根据以下内容创建您的个人代币。

这是否回答了您的问题?使用--header和我的私有令牌(顺便说一句,我以前使用过)会返回以下消息:You are being。这是因为您没有使用API url。看我上面的答案。这回答了你的问题吗?使用--header和我的私有令牌(顺便说一句,我以前使用过)会返回以下消息:You are being。这是因为您没有使用API url。见上面我的答案。