How to put two git repository into one project on sourcesup

删除回忆录丶 提交于 2021-01-29 20:25:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!