简体   繁体   English

我可以使用git代理配置从git:映射到https:吗?

[英]can I use a git proxy configuration to map from git: to https:?

I've got a repo that is only accessible via git: from some machines, and only accessible from https: from others, and I want to set up a submodule that references it. 我有一个只能在某些机器上通过git:访问的存储库,而在其他机器上只能通过https:访问,我想设置一个引用它的子模块。 Can I set up a 'proxy' that just maps from one to the other? 我可以设置一个只能映射到另一个的“代理”吗?

My suggestion is not to use the proxy setting, use the insteadof config setting: 我的建议是不要使用代理设置,而是使用代替配置设置:

[url "git@mygiturl.com"]
    insteadOf = https://theother.git.url.com/

You can set this per user, in ~/.gitconfig , or per system, usually /etc/gitconfig 您可以在~/.gitconfig为每个用户或系统设置此值,通常是/etc/gitconfig

A submodule URL can be relative to its superproject. 子模块URL可以相对于其超级项目。 Depending on how the repositories are going to be hosted, this can be used instead of recording full submodule URLs. 根据存储库的托管方式,可以使用它来代替记录完整的子模块URL。 From the git submodule add documentation : git submodule add文档

<repository> is the URL of the new submodule's origin repository. <repository>是新子模块的原始存储库的URL。 This may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject's default remote repository (Please note that to specify a repository foo.git which is located right next to a superproject bar.git, you'll have to use ../foo.git instead of ./foo.git - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories). 这可以是绝对URL,也可以是(如果以./或../开头)相对于超级项目的默认远程存储库的位置(请注意,要指定存储库foo.git,它位于超级项目的旁边) bar.git,您必须使用../foo.git而不是./foo.git-遵循相对URL规则时可能会期望-因为Git中相对URL的评估与相对URL的评估相同目录)。

When the submodule is added to the superproject it will record that relative URL instead of the full one. 将子模块添加到超级项目后,它将记录该相对URL而不是完整的URL。 When someone then clones recursively, the submodule will be cloned from the same base URL. 然后,当有人递归克隆时,将从相同的基本URL克隆子模块。 In your case, people cloning the superproject with git: URLs will also use git: URLs for the submodule, people cloning with https: URLs will also use https: URLs for the submodule. 在您的情况下,使用git: URL克隆超级项目的人也将为子模块使用git: URL,使用https: URL克隆的人也将对子模块使用https: URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM