DEV Community

Joseph Ngigi
Joseph Ngigi

Posted on • Edited on

Linking Github repositories

Git Submodules

Someone may come across a situation where they might want to link or associate two Github repositories. You may want to do this, probably for referencing on something. You need to have your two repositories ready in Github, In this tutorial, I will not go to much details on handling advanced git commands.
For both, one has the required submodule with you will put in the other that does not have it.
This is a picture of how the targeted repos

@joe-jngigi

  1. Navigate to the local git-repository that you want to add the git-submodule: In this case, I added Python_Codebase as a submodule to to the lux_data_scince repo. If you type git submodule, it will show you a few commands.

  2. To link the repos, use git submodule add <add_your_target_url>. This will clone your targeted URL into the new repo. After wards you can now push your changes to the main repository.

  3. git clone <add_your_url> --recurssive This will clone the Github repo lux_data_scince that contains the submodules. If not the gitsubmodule you added are left behind

.gitmodules is a file that shows how it links to the repo, and you can use tree to view your repo tree

  • Alternatively, you can setup git config submodule.recursive true This is if the incase of a pull/clone and you want to get all your modules

  • You can used git submodule update --init to download/update the repo submodules

The branches will not have any problems, and if you make any changes to the targeted repository, it will not affected your main repository.

Top comments (0)