我在github 上有一个库
my_library
|-- my_submodule
带.gitmodules
[submodule "my_submodule"]
path = my_submodule
url = ../my_submodule.git
branch = master
我的贡献者现在需要将repomy_library
和repomy_submodule
都分叉到他们的github,然后才能使用git clone --recurse-submodules https://github.com/<contributor_user_name>/my_library
否则他们将获得
...
Submodule 'my_submodule' (https://github.com/<contributor_user_name>/fastai-docs.git) registered for path 'docs'
Cloning into 'my_submodule'...
Username for 'https://github.com': <contributor_user_name>
Password for 'https://<contributor_user_name>@github.com':
remote: Repository not found.
fatal: repository 'https://github.com/<contributor_user_name>/my_submodule.git/' not found
fatal: clone of 'https://github.com/<contributor_user_name>/my_submodule.git' into submodule path 'my_submodule' failed
我应该怎么做,这样贡献者就不需要同时分叉my_submodule
了?
如果指定相对路径作为子模块的URL,Git将假设子模块的存储库与主存储库位于同一位置。
来自文件:
如果URL是相对于超级项目的存储库给出的,则假设超级项目和子模块存储库将放在同一相对位置,并且只需要提供超级项目的URL。git子模块将使用
.gitmodules
中的相对URL正确定位子模块。
如果您不希望您的贡献者也必须克隆子模块的存储库,您应该在.gitmodules
:中指定其绝对URL
[submodule "my_submodule"]
path = my_submodule
url = https://github.com/<your_user_name>/my_submodule.git
branch = master
这样,Git将从您的GitHub帐户而不是他们的帐户中获取子模块的存储库。
您提交了一个.gitmodules
文件,其中url
相对于根回购原点。
将此相对url替换为您的回购的绝对url:https://github.com/RichardYY/fastai-docs.git
用户(包括您自己(可以使用git-configurl.[replacement url].insteadOf
(本要点中的示例(连接到本地克隆上的不同repo:
# for example : if you want to access this repo through ssh on your local clone :
git config url."git@github.com:RichardYY/fastai-docs.git".insteadOf https://github.com/RichardYY/fastai-docs.git