Monday, February 6, 2023

Share common folder between two git repo

 One common approach is to use Git Submodules.

A Git submodule allows you to include a repository as a sub-folder within another repository. The submodule remains a separate repository, but changes made to it are committed and tracked in the parent repository.

To add a submodule to a Git repository, you would run the following commands:

$ git submodule add [url_of_the_submodule_repo] [path/to/submodule] $ git commit -m "Adding submodule [name_of_the_submodule]" $ git push

You can then clone the parent repository and initialize the submodule by running:

$ git clone [url_of_the_parent_repo] $ cd [parent_repo] $ git submodule init $ git submodule update

This way, both the parent and submodule repositories will have the latest version of the submodule code. However, changes made to the submodule code will need to be committed and pushed to the submodule repository and then committed and pushed in the parent repository to propagate to other users.

for more info:

https://phoenixnap.com/kb/git-clone-submodule

No comments:

Post a Comment