git - 使用访问 token 从 GitHub 递归克隆子模块

标签 git github git-submodules

我有一个包含许多子模块的伞式存储库。我正在使用

git clone --recurse-submodules --remote-submodules https://<access_token>@github.com/user/repo.git

递归克隆所有子模块。在 Ubuntu 上,我被要求提供每个子模块的凭据,尽管它们都可以使用相同的访问 token 进行访问,我已经通过单独克隆它们进行了测试。旁注:我被要求提供用户名和密码,自 8 月 13 日以来,GitHub 不再接受这些信息。 在 Windows 上,Git 作为 Visual Studio 的一部分安装,我只需要为伞式存储库提供一次访问 token 。

我已经尝试使用 Git 凭据缓存,但没有用:

git config --global credential.helper cache

如何通过仅提供一次访问 token 递归地克隆子模块?

最佳答案

你可以做到

git config --system credential.helper store
echo "https://username:token@github.com" > ~/.git-credentials
git clone --recurse-submodules https://github.com/org/repo repo

现在从 github.com 克隆主仓库和子模块将使用此 token 。

关于git - 使用访问 token 从 GitHub 递归克隆子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68905174/

相关文章:

git - 为什么 Git 将此文本文件视为二进制文件?

git - 语法高亮差异

git - 将 git 存储库从 GitLab 转移到 GitHub - 我们可以、如何和陷阱(如果有)?

C++ 与 git 和 CMake : How to build submodules with specific parameters?

git - 如何获取 git SHA 的关联引用路径?

ruby - 没有这样的文件或目录 - git ls-files -- WINDOWS

java - 在 github 存储库中托管私有(private) Maven Artifact

git - 如何跟踪未跟踪的内容?

git - 致命的 : Not a git repository: git status works. 但是 git 添加。没有

git - 将文件添加到一个git分支