gpt4 book ai didi

git - 如何 git checkout commit 并让子模块更新到该提交?

转载 作者:太空狗 更新时间:2023-10-29 13:22:57 24 4
gpt4 key购买 nike

我正在克隆一个带有子模块的项目并恢复到大约一年前的提交:

$ 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/pyside2sources/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 ..

最佳答案

至少尝试:

cd /path/to/main/project
git submodule update --init --recursive

那应该能够在正确的 SHA1 上克隆你的子模块

关于git - 如何 git checkout commit 并让子模块更新到该提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45624393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com