Colaboratory - 从 github 访问私有存储库

Colaboratory - access to private repository from github

在 colaboratory 中,我可以使用“!”执行 bash 命令符号像 bash !git clone repository-name 用于克隆 github 存储库。

它在存储库为 public 时运行良好,但在 存储库为私有 时不起作用,因为它需要用户名/密码而无需输入。 我该如何解决这个问题?

非常感谢!

有关信息,执行“!git something”将检索以 git 开头的最后一个命令,并向其附加 "something"。
不管怎样,你对我的错误似乎暗示你在你以前的 git 命令或 "repository-name" 中有一列,并且该列后面是 "a"

您可以从 url 本身传递用户名和密码:-

!git clone https://username:password@github.com/username/repository.git

我认为git现在克隆时不支持一行输入密码根据:https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ ; but I found this: https://medium.com/@purba0101/how-to-clone-private-github-repo-in-google-colab-using-ssh-77384cfef18f

自 2021 年以来,Github 已从使用用户名和密码迁移到使用个人访问令牌。

为了使用个人访问令牌克隆您的存储库

  1. 导航到 https://github.com/settings/tokens
  2. 点击“生成新令牌”,并提供适当的权限并定义到期日期。请为它分配一个注释以便您记住它的用途,然后单击生成令牌。
  3. 复制令牌并将其保存在安全的地方 space。 4 要克隆 repo 使用->git clone https://<PERSONAL_ACCESS_TOKEN>@github.com/username/repo.git