Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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 clone--递归,不提取最新的子模块_Git_Github_Git Submodules - Fatal编程技术网

git clone--递归,不提取最新的子模块

git clone--递归,不提取最新的子模块,git,github,git-submodules,Git,Github,Git Submodules,出于某种原因,git命令git clone--递归git@github.com:foo/bar.git未从 子模块 对于子模块“sub”,它将返回到较旧的提交: $ cd other/sub/ $ git log | head -1 commit 57d0df7269949ef6d5347c5a4556fde7eafef16d $ grep -r 57d0df7269949ef6d5347c5a4556fde7eafef16d .git/* .git/modules/other/sub/HE

出于某种原因,git命令
git clone--递归git@github.com:foo/bar.git
未从 子模块

对于子模块“sub”,它将返回到较旧的提交:

$ cd other/sub/
$ git log | head -1
commit 57d0df7269949ef6d5347c5a4556fde7eafef16d

$  grep -r 57d0df7269949ef6d5347c5a4556fde7eafef16d .git/*
.git/modules/other/sub/HEAD:57d0df7269949ef6d5347c5a4556fde7eafef16d
.git/modules/other/sub/logs/HEAD:b0e43d8acf9fc38257b20ab7317b2b86110e8f72 57d0df7269949ef6d5347c5a4556fde7eafef16d Me
<me@hello.com> 1394764688 +0530     checkout: moving from master to 57d0df7269949ef6d5347c5a4556fde7eafef16d
$cd其他/sub/
$git log|头-1
提交57d0df7269949ef6d5347c5a4556fde7eafef16d
$grep-r 57d0df7269949ef6d5347c5a4556fde7eafef16d.git/*
.git/modules/other/sub/HEAD:57d0df7269949ef6d5347c5a4556fde7eafef16d
.git/modules/other/sub/log/HEAD:b0e43d8acf9fc38257b20ab7317b2b86110e8f72 57d0df7269949ef6d5347c5a4556fde7eafef16d Me
1394764688+0530签出:从主控移动到57d0df7269949ef6d5347c5a4556fde7eafef16d
知道为什么会这样吗

at的一个答案表明,我可能将子模块固定到特定的sha,作者说这是正确的方法。在我的例子中,当我进行克隆时,我想在我的主repo和它所指的所有子模块中获取最新的

如何确认子模块是否固定到sha 57d0df7269949ef6d5347c5a4556fde7eafef16d?如何删除它

谢谢。

git子模块总是固定在特定的提交上——这就是子模块的工作方式——并且提交记录在父存储库中。这是为了确保某种程度的健全性——如果多人克隆父存储库,即使子模块存储库中有其他提交,他们也将获得相同版本的子模块

如果要更新子模块提交,需要首先更新子模块:

cd submodule
git checkout master
git pull
然后在父存储库中记录新提交:

cd ..
git commit -m 'updated submodule' submodule
git ls-tree master: | grep <directory_name>
如果要查看子模块固定到的提交,只需运行
git submodule
,它将返回如下输出:

773d95e1dce80acea254465e896394a2eb158336 _posts (heads/posts)
94a6903384ca271b7e6ff74443ac2eddaf1d1da4 assets (heads/assets)
第一个字段是提交id。您也可以在git ls tree中看到它;对于存储库顶层中的子模块:

cd ..
git commit -m 'updated submodule' submodule
git ls-tree master: | grep <directory_name>
git-ls-tree-master:| grep
对于不在顶层的子模块:

git ls-tree master:path/to/parent | grep <directory_name>
git-ls-tree-master:path/to/parent | grep
这应该显示与git子模块相同的信息