Open a file directly from a GitLab private repository

前端 未结 3 808
终归单人心
终归单人心 2020-12-25 14:51

I have a private repository on a GitLab server and using the SSH I can pull a project using git clone.

But I want to run a script on linux command line directly from

3条回答
  •  离开以前
    2020-12-25 14:57

    If you would like to access a file from private GitLab, you could use the below approach which worked for me:)

    Construct the URL:

    https://url/api/v4/projects/projectId/repository/files/fileName/raw?ref=master&private_token=Generated_private_token


    • url is your Gitlab url ex: git.lab.com.
    • /api/v4/projects is a constant.
    • projectId is the projectId of your project, which you can find below the name of your project in gitlab.
    • /repository/files is again a constant.
    • fileName is the name of the file ex: sagar.txt
    • /raw?ref= is a constant and the value of ref can be master or any branch which you would like to take the file from. I am retrieving the file from Master.
    • Generated_private_token should be generated from gitlab, please follow the steps in mentioned in the link : Generate Private Token

提交回复
热议问题