Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git pull在子模块中时将创建另一个子模块_Git_Pull_Git Submodules - Fatal编程技术网

Git pull在子模块中时将创建另一个子模块

Git pull在子模块中时将创建另一个子模块,git,pull,git-submodules,Git,Pull,Git Submodules,我在处理子模块时遇到了git pull的一个主要问题。我以为我开始理解他们的原理,但显然不是 我创建了一个简单的git repoSuper,并在其中创建了一个子模块module。我的第一个问题是,当在模块中提交(我添加了一个文本文件)并推送代码时,我可以在github上看到文本文件没有进入子模块模块,但实际上进入超级项目超级(子模块甚至没有在github中显示)。因此,当我进行git拉入Super时,我最终得到的是我的回购协议的本地副本中的文本文件,我已经将该文本文件推入了我的子模块中。。。我不

我在处理子模块时遇到了git pull的一个主要问题。我以为我开始理解他们的原理,但显然不是

我创建了一个简单的git repo
Super
,并在其中创建了一个子模块
module
。我的第一个问题是,当在
模块
中提交(我添加了一个文本文件)并推送代码时,我可以在github上看到文本文件没有进入子模块
模块
,但实际上进入超级项目
超级
(子模块甚至没有在github中显示)。因此,当我进行git拉入
Super
时,我最终得到的是我的回购协议的本地副本中的文本文件,我已经将该文本文件推入了我的子模块中。。。我不确定我做错了什么。下面是代码:

   cd module (a text file "Test" was added to be commited)
   ~/Super/module [master]: git add -A
   ~/Super/module [master]: git commit -m 'comment'
   ~/Super/module [master]: git push
   cd Super
   ~/Super [master] : git pull
   and now the text file "Test" shows up in my Super next to the submodule "module".
这已经有问题了,但我可以接受。我现在进入我的
Super
并删除此文本文件,并添加对子模块
module
所做的更改,以便重新指向最新的子模块提交

(after deleting the text file )
~/Super [master] : git add -A
~/Super [master] : git commit -m 'comment 2'
~/Super [master] : git submodule update
~/Super [master] : git pull
~/Super [master] : git push
我现在进入我的子模块,做一个git拉动

~/Super/module [master]: git pull
这将创建超级内存中所有内容的副本,并将其放入子模块
模块
。因此,如果我在
模块
中执行
ls
,我会发现一个嵌套的子模块
模块
,这是一个大问题

~/Super/module/module [master]: 
所以我基本上有两个问题:

  • 当我推我的子模块时,一个副本将被发送到超级项目

  • 在更新超级项目后拉入子模块时,它会创建一个嵌套的子模块

有人能告诉我我做错了什么吗?我很抱歉,如果这对你们来说可能是显而易见的,但我已经在这个问题上停留了一段时间,这是非常令人沮丧的

我已从Super中添加了.gitmodules文件和.git/config:

.git模块:

[submodule "module"]
path = module
url = git@github.com:titocazou/Super.git
.git/config:

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:titocazou/Super.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "module"]
url = git@github.com:titocazou/Super.git

在我看来,您可能为子模块设置了错误的远程路径,因此子模块实际上指向了与父存储库共享的远程路径。(基本上,您已经在存储库内部复制了存储库。)


检查.gitmodules的内容,查看子模块实际指向的推拉远程路径,并确保它与父存储库的推拉路径不同。

如果您可以将
.gitmodules
文件的内容添加到超级存储库中,会有所帮助,以及Super和module repos中
.git/config
的内容。非常感谢您的快速回答!我认为它可能来自.gitmodules URL(因为超级URL和模块URL匹配),但我应该将它们改成什么呢?(我已经在我的问题中添加了.gitmodules和.git/config文件)子模块被设计成一个完全独立的存储库(只是嵌入到不同存储库的目录树中)。您需要为子模块创建第二个存储库,并将子模块指向该存储库。然而,另一个问题是。。。首先,您想使用子模块做什么?