10

I have a project in my computer with the following structure:

.
├── bin
├── code
│ └── src
├── data
├── doc
├── experiments
└── reports
└── summary

code/src and /reports/summary are submodules defined in .gitmodules

[submodule "code/src"]
path = code/src
url = ./code/src/

[submodule "reports/summary"]
path = reports/summary
url = /home/zunbeltz/Proyectos/reports/base/

I created a project in the gitlab of my workplace (version 7.9.4). After adding the new origin and git push -u origin master The links of the submodules are broken with a 500 error code.

I tried also in gitlab.com, (version 7.14) and I get a 404 error

Does someone know what is going here?

Note: I did post this message on the gitlab forum, but have any answer.

zunbeltz
  • 289
  • 1
  • 3
  • 11
  • You definitely can use relative remote URLs for submodules if you want them coming from the same GitLab server as superproject. Just figure out correct amount of '../' parts of the path. – Ivan Feb 22 '18 at 10:08

1 Answers1

7

The idea of submodule is to reference nested git repo with an url that you can access.

./code/src/ and /home/zunbeltz/Proyectos/reports/base/ are file-based url that you can access locally.
But once pushed on Gitlab, said Gitlab wouldn't know how to interpreted/access those urls.
Hence the broken links.

As mentioned in the discussion:

On Gitlab, you would have to have 3 repos:

  • one for the parent repo
  • one for each submodules

In the parent repo on GitLab, you would see the same structure as on the local parent repo except GitLab would use a special icon to represent that folder.
That would represent a gitlink, a special entry in the index of a repo.

Ivan mentions in the comments the now (2018, three years later) official documentation "Using Git submodules with GitLab CI".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 2
    I agree for the absolute path (this is may mistake, it is one of several trials I did). But gitlab should now the one with relative path. – zunbeltz Sep 15 '15 at 07:05
  • Maybe should i change the remote for the submodule (but which one?) and push the submodule? – zunbeltz Sep 15 '15 at 07:07
  • 1
    @zunbeltz yes: the url of the submodules should be a gitlab url, which in turn would show this kind of icon on Gitlab: http://stackoverflow.com/q/24242490/6309 – VonC Sep 15 '15 at 07:08
  • But can I put the submodule "by hand" inside the main repository? Should I use the url `https://gitlab.com/zunbeltz/bs-calenatmiento-prueba/tree/master/reports/summary` or `https://gitlab.com/zunbeltz/bs-calenatmiento-prueba/reports/sumary.git'? – zunbeltz Sep 15 '15 at 07:15
  • @zunbeltz the link should be `https://gitlab.com//`. To change the url of a submodule: http://stackoverflow.com/a/914090/6309 – VonC Sep 15 '15 at 07:17
  • So I have to make a new gitlab project to host the submodule? – zunbeltz Sep 15 '15 at 07:27
  • @zunbeltz a submodule is just a repo. If you have a repo on GitLab, you can declare that same repo url as a submodule in your own repo. – VonC Sep 15 '15 at 07:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89648/discussion-between-zunbeltz-and-vonc). – zunbeltz Sep 15 '15 at 07:49
  • 1
    Well, that's not entirely true. We use relative URLs of submodules in .gitmodules file, because we use repos from the same GitLab server. Relative URL gets translated (git submodule sync) to correct absolute URL in .git/config. Relative paths help a lot with renaming\moving of the GitLab server. – Ivan Feb 22 '18 at 10:08
  • @Ivan Good point. Did you had an issue with submodules in GitLab? – VonC Feb 22 '18 at 10:25
  • 1
    @VonC, with relative ones - not really, with absolute remote URLs - yes, they are pain in one place, as we want to rename our GitLab server now. BTW, GitLab now officially recommends using relative ones: https://docs.gitlab.com/ce/ci/git_submodules.html – Ivan Feb 22 '18 at 10:29
  • 2
    @Ivan OK. Thank you for the link. I have included it in the answer for more visibility. – VonC Feb 22 '18 at 10:33