问题
Hi every body I'm student in master degres I work at INRAE.
I have a problem when trying to clone different repositories into one :
I have a git project "p1"
git project "P2"
and I want to create a project "Project" on sourcesup and then add the two projects.
at the end I want to have a tree like this
-Project
--------P1
--------P2
I tried a lot of commands but nothings works or give me what I'm searching for
I hope I will finf a solution with your help
Thank you
回答1:
GIT has a feature called submodules where you can have multiple git repositories inside a main repository. You can then clone the small main project independently from the sub projects. Mediawiki uses this approach to separate skins from the main project
https://git-scm.com/book/en/v2/Git-Tools-Submodules
The submodule will be empty when you clone the main project, except for the .git/config which allows you to update the submodule after the main repository
git submodule update --init
You can clone the submodules together with the main project with the recurse-submodules flag
git clone --recurse-submodules https://github.com/chaconinc/MainProject
If you don't want to have independent git repositories but merge the two project, you can use git merge where you need the flag --allow-unrelated-histories to allow them to have independent histories.
https://git-scm.com/docs/git-merge
来源:https://stackoverflow.com/questions/65391844/how-to-put-two-git-repository-into-one-project-on-sourcesup