我正在尝试使用 wget 从 github 私有(private)项目 获取原始文件。通常如果我的项目是公开的,那就很简单
For Public Repo This is my repo url (you don't have to click on it to answer this question)
https://github.com/samirtendulkar/profile_rest_api/blob/master/deploy/server_setup.sh
在我舔原始之后我的 URL 看起来像这样
https://raw.githubusercontent.com/samirtendulkar/profile_rest_api/master/deploy/server_setup.sh (注意只有单词“raw”添加到 URL)
我做的太棒了
ubuntu@ip-172-31-39-47:~$ wget https://raw.githubusercontent.com/samirtendulkar/profile_rest_api/master/deploy/server_setup.sh
当我执行 ls
时,它显示文件已下载
ubuntu@ip-172-31-39-47:~$ ls
'server_setup.sh'
For a Private repo The raw file comes with a token
https://github.com/samirtendulkar/my_project/blob/master/deploy/server_setup.sh
到目前为止一切顺利 现在,当我单击 Raw(见上图)时,我的 URL 发生了变化,并且其中有一个标记以及“raw”前缀
该 url 具有这些额外参数 ?token=AkSv7SycSHacUNlSEZamo6hpMAI6ZhsLks5b4uFuwA%3D%3D
我的 wget 不工作。我该如何解决这个问题。顺便说一下,当我说它不起作用时,我的意思是 ls
显示
ubuntu@ip-172-31-39-47:~$ ls
'server_setup.sh'
如下图所示
ubuntu@ip-172-31-39-47:~$ chmod +x server_setup.sh
和
ubuntu@ip-172-31-39-47:~$ sudo ./server_setup.sh
最佳答案
token 来自个人访问 token 部分,您可以在 Github 中找到详细信息.
使用个人访问 token ,您可以创建一个并选择第一个选项“repo”,以获得对 token 的私有(private)存储库的访问控制。
下一行解决了我无法下载文件的问题。
希望对你有帮助
wget --header 'Authorization: token PERSONAL_ACCESS_TOKEN_HERE' https://raw.githubusercontent.com/repoOwner/repoName/master/folder/filename
关于linux - 从 Github 的私有(private)仓库中获取原始文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53083479/