我正在克隆一个带有子模块的项目,并在大约一年前恢复到提交:
$ git clone --recursive --branch 5.6 https://codereview.qt-project.org/pyside/pyside-setup
$ cd pyside-setup
$ git checkout 8913156381b7dc51f903b9e459c143fb25097cab
M sources/pyside2-examples
M sources/pyside2-tools
Note: checking out '8913156381b7dc51f903b9e459c143fb25097cab'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 89131563... Adding sync.profile file for Qt CI usage
如果我进入其中一个git子模块,它们是空的:
$ ls -alh sources/pyside2
total 0
drwxr-xr-x 2 fredrik staff 68B Aug 11 00:12 ./
drwxr-xr-x 7 fredrik staff 238B Aug 11 00:12 ../
在提交8913156381b7dc51f903b9e459c143fb25097cab
(主项目)时检查子模块的最佳方法是什么?
在这种特殊情况下,我只有两个子模块。但是如果该项目有更多的子模块呢?
编辑#1:我正在使用Git 2.14.1。我可以在8913156381b7dc51f903b9e459c143fb25097cab
in the git web viewer, here查看主要项目的提交详情。如果我单击“树”链接(“树”哈希旁边),我可以view the project at that commit。遍历子模块sources/pyside2
和sources/shiboken2
,我发现他们当时都在提交c764273e64896215730e44eb907cd3535596ade4
。
但如果我手动尝试检查这些子模块,他们的目录仍然是完全空的:
$ cd sources/pyside2
$ git checkout c764273e64896215730e44eb907cd3535596ade4
HEAD is now at c764273e... Fix OS/X inclusion of framework headers.
$ ls -alh
total 0
drwxr-xr-x 2 fredrik staff 68B Aug 11 00:12 .
drwxr-xr-x 7 fredrik staff 238B Aug 11 00:12 ..
答案 0 :(得分:3)
至少尝试:
cd /path/to/main/project
git submodule update --init --recursive
应该可以在右边的SHA1
克隆你的子模块