首页 > 解决方案 > git clone --recurse-submodules 记录子模块的绝对路径

问题描述

git clone --recurse-submodules正在记录子模块的绝对路径。

也就是说,当我克隆父目录时,gitdir每个子模块的 .git 文件夹中的值都记录了子模块的绝对路径,这使得我无法移动新克隆的目录,而所有子模块都无法使用。

在原始存储库中,我首先制作子模块的 .git 文件如下所示:

gitdir: ../../.git/modules/data/scta-codices

但是在使用 git clone --recurse-submodules git@github.com:scta/scta-rdf.git 克隆到一个新目录后,.git 文件看起来像:

gitdir: /Users/username/Desktop/scta-rdf/.git/modules/data/scta-projectfiles

关于出了什么问题的任何想法?

这是 .gitmodules 文件在父目录中的样子:

[submodule "data/scta-projectfiles"]
    path = data/scta-projectfiles
    url = https://github.com/scta/scta-projectfiles
    branch = master
[submodule "data/scta-codices"]
    path = data/scta-codices
    url = https://github.com/scta/scta-codices
    branch = master
[submodule "data/scta-quotations"]
    path = data/scta-quotations
    url = https://github.com/scta/scta-quotations
    branch = master
[submodule "data/lombardpress-lists"]
    path = data/lombardpress-lists
    url = https://github.com/lombardpress/lombardpress-lists
    branch = master
[submodule "data/scta-rdf-schema"]
    path = data/scta-rdf-schema
    url = https://github.com/scta/scta-rdf-schema
    branch = master
[submodule "data/scta-people"]
    path = data/scta-people
    url = https://github.com/scta/scta-people
    branch = master

标签: gitgit-submodules

解决方案


This is actually fixed in Git v2.8.3, released in May 2016. Although the commit message might not look like it, and there was no release note entry either, this is the actual fix (I verified it by bisecting the git with itself).

See also the mailing list discussion which led to the fix of this bug.

The problematic Git version is still present in Ubuntu 16.04 LTS, for example.


推荐阅读