使用访问令牌从 GitHub 递归克隆子模块

HJP*_*HJP 5 git github git-submodules

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

git clone --recurse-submodules --remote-submodules https://<access_token>@github.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)

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

我已经尝试使用 Git 凭证缓存,但这不起作用:

git config --global credential.helper cache
Run Code Online (Sandbox Code Playgroud)

如何通过仅提供一次访问令牌来递归克隆子模块?

Mat*_*rro 4

你可以做

git config --system credential.helper store
echo "https://username:token@github.com" > ~/.git-credentials
git clone --recurse-submodules https://github.com/org/repo repo
Run Code Online (Sandbox Code Playgroud)

现在从 github.com 克隆主存储库和子模块将使用此令牌。