通过在命令中传递令牌以非交互方式克隆 git 存储库

Roh*_*ith 6 git git-clone

我在 Github 服务器上有一个名为“ helloworld ”的存储库 - github.infra.com,但该存储库的子模块来自不同的 Github 服务器。

现在我想通过在 git clone 命令中传递个人访问令牌来递归地克隆我的“ helloworld ”存储库。

像这样的东西:git clone --recursive "https://x-token-auth:<token>@<repo_url>"。如果所有内容都在单个 Github 服务器中,则此方法有效。但不是我的情况..!有人可以在这里帮助我吗?

Von*_*onC 9

不要尝试直接在命令行上传递这些凭据:您可以在全局配置中设置它们,并且 git 将使用它们。

使用url.<base>.insteadOf指令:

git config --global url."https://x-token-auth:<token>@<repo_url>".InsteadOf https://<repo_url>
git config --global url."https://x-token-auth:<token2>@<repo_url2>".InsteadOf https://<repo_url2>
Run Code Online (Sandbox Code Playgroud)

然后做你的git clone --recursive.