gitgit-submodules

git submodule relative url with different org


I have a git repo at git@someserver.com:some-org/some-repo.git.

I have another git repo at git@someserver.com:other-org/other-repo.git.

I want to add other-repo as a submodule in some-repo.

How do I make the submodule url relative?

I have attempted:

  url = ../other-org/other-repo.git

This results in git attempting to fetch

git@someserver.com:some-org/other-org/other-repo.git

which is obviously wrong.


Solution

  • Solution:

    url = ../../other-org/other-repo.git
    

    Explanation: the first ../ applied to the URL git@someserver.com:other-org/other-repo.git makes it git@someserver.com:other-org/. The second ../ makes it git@someserver.com:. Then other-org/other-repo.git appended which makes the new URL git@someserver.com:other-org/other-repo.git.