windows - Git 子模块 - 无法使用适用于 Windows 的 Linux 子系统访问存储库
问题描述
我正在尝试将 Git 子模块添加到不同的存储库。我创建了我想要的存储库,但子模块是由我的顾问创建的。
为方便起见,假设我要添加的子模块是存储库 A,而我要添加的子模块是存储库 B。
几点注意事项:
- 我正在使用适用于 Windows 的 Linux 子系统(即 Ubuntu 终端应用程序)。
- 我有一个活跃的互联网连接,并且可以通过标准 git 命令(git pull、push、commit 等)访问这两个存储库
- 我可以使用指向 A 的符号链接让我的所有代码正常工作。
这是我将 A 添加到 B 以及相应的终端输出所采取的步骤。
In: git submodule add git@gitlab.com:Respository_B
上面的行工作正常,我可以在 .gitmodules 文件中看到正确的信息,这是输出:
[submodule "Repository_B"]
path = repository_B
url = git@gitlab.com:Repsitory_B
现在,我尝试了以下两件事:
In: git submodule init
Out: fatal: No url found for submodule path 'submodule_A' in .gitmodules
和,
In: git submodule update --remote
Out: setsockopt IPV6_TCLASS 8: Operation not permitted:
我难住了。我尝试在网上搜索解决方案,但空手而归。有想法该怎么解决这个吗?
另外,如果我需要澄清任何事情,请告诉我。
谢谢!
编辑
我刚刚读到Windows 子系统存在一些 chmod 问题,所以我尝试了这一行并得到了不同的错误消息。
In: sudo git submodule update --remote
Out: git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Unable to fetch in submodule path 'Repository_A'
这很奇怪,因为我可以使用指向本地克隆的符号链接来访问存储库。
解决方案
我正在尝试添加的是存储库 A,而我尝试将其添加到的是存储库 B。
那么命令将是:
cd /path/to/B
git submodule add git@gitlab.com:Respository_A
git commit -m "Add A to B"
git push
关于错误消息,此问题表明:
我们正在使用的解决方法是将以下行放在 ~/.ssh/config 中:
AddressFamily inet
注意:如果您要连接到 IPv4 主机,则使用 AddressFamily inet 效果很好。如果主机仅为 IPv6,则根本无法连接。
推荐阅读
- database - 一对一关系与一对多关系
- javascript - 如何在函数之外获取数据,我尝试使用全局变量但它不起作用?
- python - 删除子字符串时结果中没有双空格的最佳正则表达式(在 Python 中)?
- sql - 计算连续并发调用 SQL Server
- ios - 重新排序表格视图中的行并在重新加载或关闭应用程序后保存顺序
- blazor - Blazor WASM 客户端未连接到服务器控制器(已部署实例
- javascript - 使用 QuerySelectorAll 获取页面源中的元素
- python - 熊猫就地填充变化意味着
- scala - 使用 tell 构建 Rest API
- python - 如何在另一个 Python 文件的另一个函数中使用一个函数的计算值?