使用相对URL的Git子模块 [英] Git submodules using relative urls

查看:107
本文介绍了使用相对URL的Git子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用git(TortoiseGit 1.7.5.0)并有一个包含子模块的存储库,这些子模块通过绝对路径以以下方式引用:

I use git (TortoiseGit 1.7.5.0) and have a repo with submodules, which are referenced via absolute paths in a manner:

[submodule "common/sub"]
path = common/sub
url = ssh://localhost/lib/common/sub

虽然超级存储库被克隆为ssh://user@localhost/super,但用户名不应进入每个子模块url,因为不同的用户应使用自己的凭据来处理代码.
拉/推子模块时,我必须输入登录名(因为我正在运行Pageant,所以不需要密码):用户名未通过命令行传递给TortoisePlink.

While the super-repo is cloned as ssh://user@localhost/super, the username shouldn't go into each submodule url, because different users should work with the code using their own credentials.
When pulling/pushing submodules I had to enter my login (the password is not needed because I'm running Pageant): the username isn't passed to TortoisePlink via command line.

在网上冲浪,我发现了几篇文章,提到了子模块的相对URL ,但显然,这种方法在TortoiseGit中效果不佳:我尝试了几种格式-程序经常崩溃. 无论如何,我成功采用了以下格式:

Surfing the Web, I found several posts mentioning relative urls for submodules, but apparently such approach doesn't work well with TortoiseGit: I tried several formats - the program often crashes. Anyway I succeeded with the format like:

[submodule "common/sub"]
path = common/sub
url = ../common/sub

文件.git/config中填充了正确的绝对URL,但之后TortoiseGit崩溃了...

The file .git/config is populated with the proper absolute urls, but after that TortoiseGit just crashes...

我已经审查了其他选项,包括:

I've reviewed other options including:

  1. 使用 gitolite (根据建议的此处),但这看起来像是一种过于复杂的解决方案.

  1. use gitolite (as proposed here) or sdorra (as proposed here), but this looks like an overcomplicated solution.

按照子树合并策略(作为建议此处). 看起来不错.

follow subtree merge strategy (as proposed here). It looks like a nice approach.

一种可行的解决方法是使用非标准" URL初始化子模块,如此处).

One of the working workarounds is to initialize the submodule with a "non-standard" URL as explained at the end of git Submodules Explained (the link was found here).

我认为一些更简单的解决方法可能对我有帮助(例如在某些本地配置文件中或通过命令行提供默认登录名),但是我没有找到任何可行的提示.

I suppose some simpler workaround may help in my case (like providing default login in some local config file or via command line), but I haven't found any workable hints for that.

还有问题:在绝对URL中使用不带硬编码用户名的子模块的最简单方法是什么?

And the question: what is the easiest way of using submodules without hard-coded user names in absolute urls?

推荐答案

实际上,相对URL已与msysgit一起正常工作.我已经将其从1.7.7.1升级到1.7.8,并且崩溃也消失了.伟大的! :)

Actually relative urls works fine with msysgit already. I've upgraded it from 1.7.7.1 to 1.7.8, and crashes are gone. Great! :)

这篇关于使用相对URL的Git子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆