Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Submodules: It is possible to provide both https and ssh access to submodules?

Is it possible to provide both https and ssh access to a git submodule?

Some people might prefer to use https and some might only be able to use ssh (e.g. because they are behind an ssh tunnel).

Is it possible to provide both options of fetching submodules?

like image 694
gnzlbg Avatar asked Sep 09 '15 14:09

gnzlbg


People also ask

How does git submodules work?

Git submodules allow you to keep a git repository as a subdirectory of another git repository. Git submodules are simply a reference to another repository at a particular snapshot in time. Git submodules enable a Git repository to incorporate and track version history of external code.

Why you should not use git submodules?

Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.

What does git pull -- recurse submodules do?

If you pass --recurse-submodules to the git clone command, it will automatically initialize and update each submodule in the repository, including nested submodules if any of the submodules in the repository have submodules themselves.

When should I use git submodules?

In most cases, Git submodules are used when your project becomes more complex, and while your project depends on the main Git repository, you might want to keep their change history separate. Using the above as an example, the Room repository depends on the House repository, but they operate separately.


1 Answers

You can use relative URL when referencing a submodule.

For example if you have an application repository:

and a library repository:

then you can reference the library as ../lib/some-library.git instead of the full URL.

like image 199
Josef Kufner Avatar answered Oct 12 '22 17:10

Josef Kufner