I can clone a private repo with username & password using command below
git clone https://some-git-lab-token:[email protected]/foo/bar.git
I'm wondering if it's possible to curl
or wget
a single raw file from the same repo using the same credential some-git-lab-token:someHash
A sample gitlab raw file url as below
https://gitlab.com/athos.oc/lodash-has-plugin/-/raw/master/.eslintrc.json
I've tried to curl a single file as below but failed
curl https://some-git-lab-token:[email protected]/foo/bar/-/raw/master/testing.js
The result that I got is as below
<html><body>You are being <a href="https://git.xxx.com/users/sign_in">redirected</a>.</body></html>
CodePudding user response:
To download a repository file through curl, you need to use the repository files API endpoint.
Using your example https://gitlab.com/athos.oc/lodash-has-plugin/-/raw/master/.eslintrc.json
, would turn into:
https://gitlab.com/api/v4/projects/30349314/repository/files/.eslintrc.json?ref=master
However, API authentication does not include username and password as an available authentication method, so you would need to use a token (or a session cookie).