我有一个包含许多子模块的伞式存储库。我正在使用
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/