Git 子模块 - 无法使用 Linux 子系统访问存储库 Windows

Git Submodule - Unable to Access Repository using Linux Subsystem for Windows

我正在尝试将 Git 子模块添加到不同的存储库。我创建了我想要的存储库,但子模块是由我的顾问创建的。

为方便起见,假设我要添加的子模块是存储库 A,而我要将其添加到的子模块是存储库 B。

几个注意事项:

  1. 我正在为 Windows 使用 Linux 子系统(即 Ubuntu 终端应用程序)。
  2. 我有有效的互联网连接,可以通过标准 git 命令(git 拉取、推送、提交等)访问两个存储库
  3. 我可以使用符号 links to 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: 

我被难住了。我尝试在网上搜索解决方案,但一无所获。关于如何解决此问题的任何想法?

此外,如果我需要澄清任何事情,请告诉我。

谢谢!


编辑


just read 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'

这很奇怪,因为我可以使用对本地克隆所做的符号 link 访问存储库。

I'm trying to add is repository A and the one I'm trying to add it to is repository B.

那么命令将是:

cd /path/to/B
git submodule add git@gitlab.com:Respository_A
git commit -m "Add A to B"
git push

关于错误信息,this issue建议:

A workaround that we are using is to put the following line in ~/.ssh/config:

AddressFamily inet

Note: Using AddressFamily inet works great if you're connecting to an IPv4 host. If the host is IPv6 only, it won't connect at all.