linux - 从 Github 的私有(private)仓库中获取原始文件

标签 linux git amazon-web-services ubuntu github

我正在尝试使用 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

我点击raw enter image description here

在我舔原始之后我的 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”前缀

https://raw.githubusercontent.com/samirtendulkar/my_project/master/deploy/server_setup.sh?token=AkSv7SycSHacUNlSEZamo6hpMAI6ZhsLks5b4uFuwA%3D%3D

该 url 具有这些额外参数 ?token=AkSv7SycSHacUNlSEZamo6hpMAI6ZhsLks5b4uFuwA%3D%3D

我的 wget 不工作。我该如何解决这个问题。顺便说一下,当我说它不起作用时,我的意思是 ls 显示

ubuntu@ip-172-31-39-47:~$ ls
    'server_setup.sh'

如下图所示

enter image description here 这不会让我运行更多的命令,比如

ubuntu@ip-172-31-39-47:~$ chmod  +x server_setup.sh

ubuntu@ip-172-31-39-47:~$ sudo ./server_setup.sh

我需要将项目转移到 AWS enter image description here

最佳答案

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/

相关文章:

linux - 有没有办法查看谁在 Linux 中查看/访问了文件?

macos - 终端打开时显示 'No such file or directory'

amazon-web-services - 为什么我的 AWS RDS 备份的保留时间比配置的时间长?

linux - AWS CLI S3 复制 (cp) 命令在成功和不成功尝试时都返回 0(零)状态代码 - 这是正确的行为吗?

linux - 消除 LINUX 中第一个和最后一个空格或制表符

linux - Bash shell `if` 命令返回一些东西 `then` 做一些事情

git - 在 Media Temple 服务器上克隆 git 存储库

git - 如何创建依赖于托管在 gitlab 子组中的私有(private) go 包的 docker 镜像?

amazon-web-services - 无法部署用 Go 编写的 lambda 函数

amazon-web-services - 如何防止使用签名网址从亚马逊云端下载视频