我如何从Travis CI .org克隆一个私有GitHub存储库

问题描述 投票:0回答:1

我很难在Travis CI脚本中克隆私有存储库。

我不需要存储库的功能齐全的工作副本,我只需要存储库的单个分支中的脚本。

如何在不将个人信息烘烤到存储库的情况下从命令行克隆该GitHub存储库?

github travis-ci credentials
1个回答
0
投票

最简单的方法是到分支pull,而不是clone整个存储库。

首先,您需要从您的GitHub帐户生成一个对私有存储库具有特权的“ 个人访问令牌”。然后创建您想要将存储库下载到的文件夹。然后git init文件夹,然后使用OAuth git pull分支。

$ mkdir new_dir
$ pushd new_dir
~/new_dir ~/old_dir
$ git init
Initialized empty Git repository in /home/you/new_dir/.git/
$ git pull https://<personal_access_token>:[email protected]/<user>/<repo>.git
From https://github.com/<user>/<repo>
 * branch            HEAD       -> FETCH_HEAD
$ popd
© www.soinside.com 2019 - 2024. All rights reserved.