git submodule init does absolutely nothing

前端 未结 3 1907
傲寒
傲寒 2021-01-07 19:36

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 ever

3条回答
  •  悲&欢浪女
    2021-01-07 20:16

    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!

提交回复
热议问题