我有一个带有子模块的git,其中子模块进行了修改/提交,而这些修改/提交还没有被推送到它起源的远程。
我想用子模块克隆这个父回购,并保留修改,同时保持我试图克隆的git历史记录(这包括子模块中的修改)。
我尝试过git clone --recurse-submodules https://some.domain.ca/path/to/repo.git
,但这会导致以下错误
fatal: git upload-pack: not our ref 063e202da5c92a701892a121db16e5c66d661725
fatal: remote error: upload-pack: not our ref 063e202da5c92a701892a121db16e5c66d661725
Fetched in submodule path 'submodule-name', but it did not contain 063e202da5c92a701892a121db16e5c66d661725. Direct fetching of that commit failed.
我认为发生此错误是因为回购中的子模块的历史记录与其起源的远程模块的历史不匹配。
如何使用子模块及其未在子模块引用中表示的修改克隆回购?
发布于 2022-10-12 18:02:59
larsks的评论对于思考如何在子模块中引用所需的提交具有指导意义。
下面是使用修改后的子模块复制初始回购的步骤:
git clone https://some.domain.ca/path/to/repo.git
git submodule update --init --recursive
.gitmodules
中的url以引用源repo
git submodule update --init --recursive
.gitmodules
。
这确实意味着子模块中的任何进一步修改对于其他克隆来说都是未知的,但是可以重复这些步骤来进行更新。
https://stackoverflow.com/questions/74044826
复制相似问题