git子模块init完全没有 [英] git submodule init does absolutely nothing

查看:180
本文介绍了git子模块init完全没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,git submodule init

当我使用git submodule add url location添加子模块时,它克隆了存储库, 当我将所有更改推回到父库时,添加了.gitmodules文件等,并将库克隆回来时,我尝试初始化所有子模块使用git submodule init



没有任何事情发生:(没有任何东西,没有输出,没有额外的文件,它甚至不会尝试做任何事情。



所以我想知道,我做错了什么?

.gitmodules:

  bash $ cat .gitmodules 
[submoduleprojects / subprojectA]
path = projects / subprojectA
url = ssh:// user@bitbucket.company.com/test/projectA.git

[submoduleprojects / subprojectB]
path = projects / subprojectB
url = ssh:// user @ bitbucket.company.com/test/projectB.git




当我添加git子模块时,我已经知道我做错了什么。

我做了一个git状态,它告诉我有三件事情已经改变了:

  .gitmodules 
项目/子项目A
projects / subprojectB

当我将所有更改推送到存储库时,我不想提交子模块,因为我认为它会添加所有我刚刚克隆的文件,所以我只是做了一个git添加.gitmodules并提交并推送。



但这是错误的,你需要做一个git提交并提交它告诉你的所有内容,然后当你这样做时,git会注册这些路径,并且当你克隆时,它就会起作用。

但是如果你不要提交这些文件夹,它不会注册它们,也不会在克隆父库时克隆它们。



这是我的错误,我误解了添加这些目录会添加所有的子模块都编码到父回购站itory,我试图避开它,它停止工作。



所以只需添加你的子模块并提交结果,它就会工作得很好:D



感谢Protectator的帮助,无论如何!


I have a strange problem with "git submodule init"

When I added the submodules using "git submodule add url location" it cloned the repository just fine and everything was ok.

When I pushed all my changes back to the parent repository, added the .gitmodules files, etc and cloned the repository back, I tried to initialise all the submodules using "git submodule init"

And nothing happens :( Literally nothing, no output, no extra files, it does not even attempt to do anything actually.

So I am wondering, what did I do wrong?

.gitmodules:

bash$ cat .gitmodules
[submodule "projects/subprojectA"]
    path = projects/subprojectA
    url = ssh://user@bitbucket.company.com/test/projectA.git

[submodule "projects/subprojectB"]
    path = projects/subprojectB
    url = ssh://user@bitbucket.company.com/test/projectB.git

解决方案

ok, I have figured out what I did wrong.

When I added the git submodules, I did a git status and it told me three things had changed

.gitmodules
projects/subprojectA
projects/subprojectB

when I was pushing all my changes to the repository, I didnt want to commit the submodules, cause I thought it would add all the files I just cloned, so I just did a git add .gitmodules and committed and pushed that.

But this is wrong, you need to do a git commit and commit everything it tells you, then when you do this, git registers those paths and when you clone, it will work.

but if you do not commit those folders, it wont register them and wont clone them when you clone the parent repository.

so that was my mistake, I misunderstood that adding those directories would add all the submodules code to the parent repository, I tried to sidestep that and it stopped working.

so just add your submodules and commit the results, it will all work out just fine :D

Thanks for Protectators help, regardless!

这篇关于git子模块init完全没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆